1 条题解

  • 1
    @ 2026-4-5 9:34:54

    #include #include #include using namespace std;

    int main() { vector res; // 存储符合条件的数

    // 遍历所有三位数
    for (int num = 100; num <= 999; num++) {
        // 条件1:判断是否是完全平方数
        int s = sqrt(num);
        if (s * s != num) continue;
    
        // 拆分数字:百位、十位、个位
        int a = num / 100;
        int b = num / 10 % 10;
        int c = num % 10;
    
        // 条件2:至少两位相同
        if (a == b || b == c || a == c) {
            res.push_back(num);
        }
    }
    
    // 输入n,输出第n个(下标从0开始)
    int n;
    cin >> n;
    cout << res[n - 1] << endl;
    
    return 0;
    

    } kskbl

    信息

    ID
    2719
    时间
    10000ms
    内存
    256MiB
    难度
    10
    标签
    递交数
    2
    已通过
    2
    上传者