1 条题解

  • 0
    @ 2026-7-1 14:50:41

    Let dd be the number of digits of xx, and choose y=10d+1y = 10^d + 1. The number yy contains only the digits 00 and 11, so yy is good. Also,

    xy=x(10d+1)=x10d+x. x \cdot y = x \cdot (10^d+1) = x \cdot 10^d + x.

    Since x<10dx \lt 10^d, multiplying by 10d10^d simply shifts xx by dd positions. Therefore, xyx \cdot y is exactly the decimal concatenation of xx with itself. Hence, the set of digits appearing in xyx \cdot y is the same as in xx. Since xx is good, xyx \cdot y is good as well.

    Thus, for every test case, one of the possible answers is simply

    y=10d+1. y = 10^d + 1.

    The construction always satisfies 2y1092 \le y \le 10^9.

    Time Complexity: O(log10(x))\mathcal{O}(\log_{10}(x)).

    ddxx 的位数,并选取 y=10d+1y = 10^d + 1。数字 yy 仅包含数字 0011,因此 yy 是好的。此外,

    xy=x(10d+1)=x10d+x. x \cdot y = x \cdot (10^d+1) = x \cdot 10^d + x.

    由于 x<10dx \lt 10^d,乘以 10d10^d 相当于将 xx 向左移动 dd 位。因此,xyx \cdot y 恰好是 xx 与其自身的十进制拼接。于是,xyx \cdot y 中出现的数字集合与 xx 中的相同。由于 xx 是好的,xyx \cdot y 也是好的。

    因此,对于每个测试用例,其中一个可能的答案就是

    y=10d+1. y = 10^d + 1.

    该构造始终满足 2y1092 \le y \le 10^9

    时间复杂度:O(log10(x))\mathcal{O}(\log_{10}(x))

    Solution

    #include<bits/stdc++.h>
    using namespace std;
     
    int main(){
     
        int tt;
        cin >> tt;
     
        while(tt--){
            int x;
            cin >> x;
     
            int y = 1;
     
            while(x > 0){
                y *= 10;
                x /= 10;
            }
     
            cout << y + 1 << '\n';
        }
     
        return 0;
    }
    

    信息

    ID
    3
    时间
    1000ms
    内存
    256MiB
    难度
    (无)
    标签
    (无)
    递交数
    0
    已通过
    0
    上传者