2 solutions

  • 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;
    }
    
    • 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;
      }
      
      • 1

      Information

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