QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#179828 | #5676. Counting Pythagorean Triples | Clouds | WA | 281ms | 3548kb | C++14 | 897b | 2023-09-15 10:32:50 | 2023-09-15 10:32:50 |
Judging History
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'