1 条题解
-
2
王晟睿 LV 6 @ 2025-04-19 20:59:45
#include <iostream>
#include <cmath>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
int a;
cin >> a;
int sqrt_a = sqrt(a);
if (sqrt_a * sqrt_a != a) {
cout << "-1\n";
continue;
}
int sqrt_b = sqrt(sqrt_a);
if (sqrt_b * sqrt_b == sqrt_a) {
cout << sqrt_b << '\n';
} else {
cout << "-1\n";
}
}
return 0;
}
- 1
信息
- ID
- 2849
- 难度
- 7
- 分类
- (无)
- 标签
- 递交数
- 181
- 已通过
- 30
- 通过率
- 17%
- 上传者