#include #include using namespace std;

int main() { int t; cin >> t;

while (t--) {
    long long x;
    cin >> x;
    
    bool found = false;
    for (int k = 0; k <= 9; k++) {
        long long y = ceil(sqrt(x * pow(10, k)));
        if (y * y / pow(10, k) == x) {
            cout << y << endl;
            found = true;
            break;
        }
    }
    
    if (!found) {
        cout << -1 << endl;
    }
}

return 0;
时间限制:CC++ 1秒其他语言2秒空间限制:CC++ 262144K其他语言524288KSpecial Judge 64bit IO Format lld题目描述 Find a number 0≤y≤1090 leq yleq 10^90≤y≤109 so that the square of yyy starts with xxx in DecimalFormally given a int

原文地址: https://www.cveoy.top/t/topic/ieQm 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录