2 solutions

  • 0
    @ 2025-6-8 10:19:06
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int T;
    	cin>>T;
    	while(T--)
    	{
    		int n;
    		cin>>n;
    		int cnt=0;
    		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<<"Yes"<<endl;
    		else cout<<"No"<<endl;
    	}
    	return 0;
    }
    

    Information

    ID
    2179
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    8
    Tags
    # Submissions
    17
    Accepted
    5
    Uploaded By