QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#179829#5676. Counting Pythagorean TriplesCloudsAC ✓23ms3588kbC++14931b2023-09-15 10:34:062023-09-15 10:34:06

Judging History

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

  • [2023-09-15 10:34:06]
  • 评测
  • 测评结果:AC
  • 用时:23ms
  • 内存:3588kb
  • [2023-09-15 10:34:06]
  • 提交

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=i;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;
        int y=sqrt(x);
        if(y*y!=x) continue;
        if(x>0)
        {
            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: 100
Accepted
time: 19ms
memory: 3428kb

input:

65

output:

2 2 2 2

result:

ok single line: '2 2 2 2'

Test #2:

score: 0
Accepted
time: 18ms
memory: 3424kb

input:

64

output:

0 0 1 4

result:

ok single line: '0 0 1 4'

Test #3:

score: 0
Accepted
time: 20ms
memory: 3532kb

input:

2023

output:

0 2 2 5

result:

ok single line: '0 2 2 5'

Test #4:

score: 0
Accepted
time: 19ms
memory: 3416kb

input:

1560

output:

0 4 8 59

result:

ok single line: '0 4 8 59'

Test #5:

score: 0
Accepted
time: 19ms
memory: 3528kb

input:

1625

output:

2 8 2 8

result:

ok single line: '2 8 2 8'

Test #6:

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

input:

1888

output:

0 0 2 11

result:

ok single line: '0 0 2 11'

Test #7:

score: 0
Accepted
time: 16ms
memory: 3424kb

input:

2125

output:

2 8 2 8

result:

ok single line: '2 8 2 8'

Test #8:

score: 0
Accepted
time: 16ms
memory: 3580kb

input:

1950

output:

0 7 0 22

result:

ok single line: '0 7 0 22'

Test #9:

score: 0
Accepted
time: 20ms
memory: 3300kb

input:

2477

output:

1 0 1 0

result:

ok single line: '1 0 1 0'

Test #10:

score: 0
Accepted
time: 19ms
memory: 3412kb

input:

1728

output:

0 0 2 36

result:

ok single line: '0 0 2 36'

Test #11:

score: 0
Accepted
time: 20ms
memory: 3412kb

input:

2249

output:

2 2 2 2

result:

ok single line: '2 2 2 2'

Test #12:

score: 0
Accepted
time: 20ms
memory: 3416kb

input:

2176

output:

0 1 2 17

result:

ok single line: '0 1 2 17'

Test #13:

score: 0
Accepted
time: 20ms
memory: 3420kb

input:

2467

output:

0 0 1 0

result:

ok single line: '0 0 1 0'

Test #14:

score: 0
Accepted
time: 16ms
memory: 3584kb

input:

1898

output:

0 4 0 4

result:

ok single line: '0 4 0 4'

Test #15:

score: 0
Accepted
time: 22ms
memory: 3416kb

input:

2048

output:

0 0 1 9

result:

ok single line: '0 0 1 9'

Test #16:

score: 0
Accepted
time: 20ms
memory: 3372kb

input:

1875

output:

0 4 2 11

result:

ok single line: '0 4 2 11'

Test #17:

score: 0
Accepted
time: 21ms
memory: 3444kb

input:

2187

output:

0 0 1 6

result:

ok single line: '0 0 1 6'

Test #18:

score: 0
Accepted
time: 20ms
memory: 3432kb

input:

2431

output:

0 4 4 9

result:

ok single line: '0 4 4 9'

Test #19:

score: 0
Accepted
time: 20ms
memory: 3368kb

input:

2028

output:

0 2 4 18

result:

ok single line: '0 2 4 18'

Test #20:

score: 0
Accepted
time: 23ms
memory: 3424kb

input:

1105

output:

4 9 4 9

result:

ok single line: '4 9 4 9'

Test #21:

score: 0
Accepted
time: 17ms
memory: 3528kb

input:

2210

output:

0 13 0 13

result:

ok single line: '0 13 0 13'

Test #22:

score: 0
Accepted
time: 20ms
memory: 3408kb

input:

2465

output:

4 9 4 9

result:

ok single line: '4 9 4 9'

Test #23:

score: 0
Accepted
time: 20ms
memory: 3548kb

input:

2187

output:

0 0 1 6

result:

ok single line: '0 0 1 6'