求助,测试能过但提交全WA
查看原帖
求助,测试能过但提交全WA
1051378
hsy0824楼主2024/8/11 01:54
#include <bits/stdc++.h>
using namespace std;
bool ggs(int y){
    for (int i = 1; i*i <= y; i++){
        for (int j = 1; j*j <= y; j++){
            if (i*i+j*j == y){
                return true;
            }
        }
    }
    return false;
}
int main(){
    int n;
    cin >> n;
    int x;
    for (int i = 1; i <= n; i++){
        cin >> x;
        if (ggs(x) == true){
            cout << "Yes";
        } else {
            cout << "No";
        }
    }
    return 0;
}
2024/8/11 01:54
加载中...