QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#708688#5676. Counting Pythagorean Triplesmgoldy925#AC ✓11ms3704kbC++14691b2024-11-04 03:26:212024-11-04 03:26:22

Judging History

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

  • [2024-11-04 03:26:22]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:3704kb
  • [2024-11-04 03:26:21]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
inline int gcd(int a,int b){
    int tmp;
    while(b)tmp=a%b,a=b,b=tmp;
    return a;
}
int main(){
    int s1=0,s2=0,s3=0,s4=0;
    int x;cin>>x;
    for(int i=1;i<x;++i){
        int j=sqrt(x*x-i*i);
        if(j<i)break;
        if(i*i+j*j!=x*x)continue;
        if(gcd(gcd(i,j),x)==1)++s1;
        else ++s2;
    }

    for(int i=x+1;i<=x*x;++i){
        int j=sqrt(1ll*i*i-x*x);
        if(1ll*j*j+x*x!=1ll*i*i)continue;
        if(gcd(gcd(i,j),x)==1)++s3;
        else ++s4;
    }
    cout<<s1<<" "<<s2<<" "<<s3<<" "<<s4<<endl;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3604kb

input:

65

output:

2 2 2 2

result:

ok single line: '2 2 2 2'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

64

output:

0 0 1 4

result:

ok single line: '0 0 1 4'

Test #3:

score: 0
Accepted
time: 8ms
memory: 3632kb

input:

2023

output:

0 2 2 5

result:

ok single line: '0 2 2 5'

Test #4:

score: 0
Accepted
time: 2ms
memory: 3628kb

input:

1560

output:

0 4 8 59

result:

ok single line: '0 4 8 59'

Test #5:

score: 0
Accepted
time: 2ms
memory: 3692kb

input:

1625

output:

2 8 2 8

result:

ok single line: '2 8 2 8'

Test #6:

score: 0
Accepted
time: 7ms
memory: 3696kb

input:

1888

output:

0 0 2 11

result:

ok single line: '0 0 2 11'

Test #7:

score: 0
Accepted
time: 8ms
memory: 3588kb

input:

2125

output:

2 8 2 8

result:

ok single line: '2 8 2 8'

Test #8:

score: 0
Accepted
time: 7ms
memory: 3648kb

input:

1950

output:

0 7 0 22

result:

ok single line: '0 7 0 22'

Test #9:

score: 0
Accepted
time: 8ms
memory: 3652kb

input:

2477

output:

1 0 1 0

result:

ok single line: '1 0 1 0'

Test #10:

score: 0
Accepted
time: 6ms
memory: 3624kb

input:

1728

output:

0 0 2 36

result:

ok single line: '0 0 2 36'

Test #11:

score: 0
Accepted
time: 9ms
memory: 3692kb

input:

2249

output:

2 2 2 2

result:

ok single line: '2 2 2 2'

Test #12:

score: 0
Accepted
time: 9ms
memory: 3684kb

input:

2176

output:

0 1 2 17

result:

ok single line: '0 1 2 17'

Test #13:

score: 0
Accepted
time: 11ms
memory: 3696kb

input:

2467

output:

0 0 1 0

result:

ok single line: '0 0 1 0'

Test #14:

score: 0
Accepted
time: 7ms
memory: 3552kb

input:

1898

output:

0 4 0 4

result:

ok single line: '0 4 0 4'

Test #15:

score: 0
Accepted
time: 8ms
memory: 3692kb

input:

2048

output:

0 0 1 9

result:

ok single line: '0 0 1 9'

Test #16:

score: 0
Accepted
time: 6ms
memory: 3604kb

input:

1875

output:

0 4 2 11

result:

ok single line: '0 4 2 11'

Test #17:

score: 0
Accepted
time: 9ms
memory: 3704kb

input:

2187

output:

0 0 1 6

result:

ok single line: '0 0 1 6'

Test #18:

score: 0
Accepted
time: 11ms
memory: 3620kb

input:

2431

output:

0 4 4 9

result:

ok single line: '0 4 4 9'

Test #19:

score: 0
Accepted
time: 4ms
memory: 3652kb

input:

2028

output:

0 2 4 18

result:

ok single line: '0 2 4 18'

Test #20:

score: 0
Accepted
time: 3ms
memory: 3604kb

input:

1105

output:

4 9 4 9

result:

ok single line: '4 9 4 9'

Test #21:

score: 0
Accepted
time: 6ms
memory: 3564kb

input:

2210

output:

0 13 0 13

result:

ok single line: '0 13 0 13'

Test #22:

score: 0
Accepted
time: 11ms
memory: 3604kb

input:

2465

output:

4 9 4 9

result:

ok single line: '4 9 4 9'

Test #23:

score: 0
Accepted
time: 9ms
memory: 3604kb

input:

2187

output:

0 0 1 6

result:

ok single line: '0 0 1 6'