2 solutions

  • 1
    @ 2026-8-13 13:58:02
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n;
    	cin>>n;
    	int cnt=0;
    	for(int i=1;i<=n;i++)
    	{
    		for(int j=i+1;j<=n;j++)
    		{
    			int x=sqrt(i*j);
    			if(x*x==i*j)
    			{
                    cnt++;
    			}
    		}
    	}
    	cout<<cnt;
    	return 0; 
    }
    
    • 1
      @ 2026-5-31 11:41:31
      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          int n,cnt=0;cin>>n;
          for(int i=1;i<=n;i++)
          {
              for(int j=i+1;j<=n;j++)
              {
                  int t=sqrt(i*j);
                  if(t*t==i*j) cnt++;
              }
          }
          cout<<cnt;
          return 0;
      }
      
      • 1

      Information

      ID
      53
      Time
      1000ms
      Memory
      256MiB
      Difficulty
      1
      Tags
      (None)
      # Submissions
      182
      Accepted
      23
      Uploaded By