3 solutions

  • 4
    @ 2025-6-8 10:19:06
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int T;
    	cin>>T;
    	while(T--)
    	{
    		int a;
    		cin>>a;
    		int cnt=0;
    		for(int x=1;x<=a/x;x++) //枚举第一个数 
    		{
    			for(int y=1;y<=a/y;y++) //枚举第二个数 
    			{
    				if(x*x+y*y==a)
    				{
    					cnt++;
    				}
    			}
    		}
    		if(cnt>0) cout<<"Yes"<<endl;
    		else cout<<"No"<<endl;
    	}
    	return 0;
    }
    
    
    • 1
      @ 2025-11-15 15:59:04

      压力

      • -1
        @ 2025-6-8 10:19:37
        #include<bits/stdc++.h>
        using namespace std;
        int a[1111111];
        int main()
        {
            int T;cin>>T;
            while(T--)
            {
                int n,cnt=0;cin>>n;
                for(int i=1;i<=n/i;i++)
                {
                    for(int j=1;j<=n/j;j++)
                    {
                        if(i*i+j*j==n)
                        {
                            cnt++;
                        }
                    }
                }
                if(cnt==0) cout<<"No"<<endl;
                else cout<<"Yes"<<endl;
            }
            return 0;
        }
        
        • 1

        Information

        ID
        2179
        Time
        1000ms
        Memory
        256MiB
        Difficulty
        1
        Tags
        # Submissions
        79
        Accepted
        25
        Uploaded By