QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#100226#5676. Counting Pythagorean TriplesNicolas125841AC ✓11ms3540kbC++14879b2023-04-25 01:13:302023-04-25 01:13:31

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-25 01:13:31]
  • 评测
  • 测评结果:AC
  • 用时:11ms
  • 内存:3540kb
  • [2023-04-25 01:13:30]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
    ll n;

    cin >> n;

    int one = 0, two = 0, three = 0, four = 0;

    for(ll i = 1; i < n; i++){
        for(ll 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)
                    one++;
                else
                    two++;
            }
        }
    }

    ll v = 1;

    while(2*v + 1 <= n*n){
        //cout << v << "\n";

        if((ll)pow((ll)sqrt(v*v+n*n), 2) == v*v+n*n){
            if(__gcd(v, n) == 1 && __gcd((ll)sqrt(v*v+n*n), n) == 1 && __gcd((ll)sqrt(v*v+n*n), v) == 1)
                three++;
            else
                four++;
        }

        v++;
    }

    cout << one << " " << two << " " << three << " " << four << "\n";
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3336kb

input:

65

output:

2 2 2 2

result:

ok single line: '2 2 2 2'

Test #2:

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

input:

64

output:

0 0 1 4

result:

ok single line: '0 0 1 4'

Test #3:

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

input:

2023

output:

0 2 2 5

result:

ok single line: '0 2 2 5'

Test #4:

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

input:

1560

output:

0 4 8 59

result:

ok single line: '0 4 8 59'

Test #5:

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

input:

1625

output:

2 8 2 8

result:

ok single line: '2 8 2 8'

Test #6:

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

input:

1888

output:

0 0 2 11

result:

ok single line: '0 0 2 11'

Test #7:

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

input:

2125

output:

2 8 2 8

result:

ok single line: '2 8 2 8'

Test #8:

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

input:

1950

output:

0 7 0 22

result:

ok single line: '0 7 0 22'

Test #9:

score: 0
Accepted
time: 10ms
memory: 3288kb

input:

2477

output:

1 0 1 0

result:

ok single line: '1 0 1 0'

Test #10:

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

input:

1728

output:

0 0 2 36

result:

ok single line: '0 0 2 36'

Test #11:

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

input:

2249

output:

2 2 2 2

result:

ok single line: '2 2 2 2'

Test #12:

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

input:

2176

output:

0 1 2 17

result:

ok single line: '0 1 2 17'

Test #13:

score: 0
Accepted
time: 10ms
memory: 3292kb

input:

2467

output:

0 0 1 0

result:

ok single line: '0 0 1 0'

Test #14:

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

input:

1898

output:

0 4 0 4

result:

ok single line: '0 4 0 4'

Test #15:

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

input:

2048

output:

0 0 1 9

result:

ok single line: '0 0 1 9'

Test #16:

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

input:

1875

output:

0 4 2 11

result:

ok single line: '0 4 2 11'

Test #17:

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

input:

2187

output:

0 0 1 6

result:

ok single line: '0 0 1 6'

Test #18:

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

input:

2431

output:

0 4 4 9

result:

ok single line: '0 4 4 9'

Test #19:

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

input:

2028

output:

0 2 4 18

result:

ok single line: '0 2 4 18'

Test #20:

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

input:

1105

output:

4 9 4 9

result:

ok single line: '4 9 4 9'

Test #21:

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

input:

2210

output:

0 13 0 13

result:

ok single line: '0 13 0 13'

Test #22:

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

input:

2465

output:

4 9 4 9

result:

ok single line: '4 9 4 9'

Test #23:

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

input:

2187

output:

0 0 1 6

result:

ok single line: '0 0 1 6'