QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#179828#5676. Counting Pythagorean TriplesCloudsWA 281ms3548kbC++14897b2023-09-15 10:32:502023-09-15 10:32:50

Judging History

你现在查看的是最新测评结果

  • [2023-09-15 10:32:50]
  • 评测
  • 测评结果:WA
  • 用时:281ms
  • 内存:3548kb
  • [2023-09-15 10:32:50]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
int n;

int gcd(int a,int b)
{
    return b?gcd(b,a%b):a;
}

signed main()
{
    int n;
    cin>>n;
    int ans1=0,ans2=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i*i+j*j==n*n)
            {
                if(gcd(i,j)==1&&gcd(i,n)==1&&gcd(j,n)==1)
                    ans1++;
                else
                    ans2++;
            }
        }
    }
    cout<<ans1<<" "<<ans2<<" ";
    ans1=ans2=0;
    for(int i=1;i<=1e7;i++)
    {
        int x=i*i-n*n;
        if(x>0&&sqrt(x)*sqrt(x)==x)
        {
            int j=sqrt(x);
            if(gcd(i,j)==1&&gcd(i,n)==1&&gcd(j,n)==1)
                ans1++;
            else
                ans2++;
        }
    }
    cout<<ans1<<" "<<ans2<<endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 281ms
memory: 3548kb

input:

65

output:

4 4 5076472 4923463

result:

wrong answer 1st lines differ - expected: '2 2 2 2', found: '4 4 5076472 4923463'