1 条题解

  • 0
    @ 2025-12-6 23:47:41
    #include <bits/stdc++.h>
    using namespace std;
    
    bool chk(int n){
        for(int x=1; x*x<n; x++){
            for(int y=1; y*y<=n; y++){
                if(x*x + y*y == n) return true;
            }
        }
        return false; //所有方案都不行时,返回false
    }
    
    int main(){
        int n,t;
        cin >> n;
        //
        while(n--){
            cin >> t;
            if(chk(t)==true) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
        //
        return 0;
    }
    
    • 1

    平方之和(洛谷 B4002)(循环输入+完全平方数判断、简单枚举算法)

    信息

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