QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#726541 | #5676. Counting Pythagorean Triples | Nika# | AC ✓ | 29ms | 3812kb | C++20 | 852b | 2024-11-09 02:31:55 | 2024-11-09 02:31:55 |
Judging History
answer
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
using ll = long long;
void solve() {
ll n; cin >> n;
ll N = n*n;
set<ll> cnt = {0};
vector<int> A(4, 0);
for (ll i = 1; i < ll(6250000+5); i++){
ll I = i*i;
ll J = max(N, I)-min(N, I);
ll j = sqrtl(J);
if (j*j != J || cnt.count(j)) continue;
cnt.insert(i);
cnt.insert(j);
// cout << i << " " << j << " " << n << endl;
if (I+N == J || I+J == N || J+N == I){
int PPT = (gcd(i, j) == 1 && gcd(i, n) == 1 && gcd(j, n) == 1);
if (max({i, j, n}) == n) A[!PPT]++;
else A[(!PPT)+2]++;
}
}
for (int i: A) cout << i << " ";
cout << endl;
}
int main(){
cin.tie(0)->sync_with_stdio(0);
int t = 1;
// cin >> t;
while(t--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 29ms
memory: 3552kb
input:
65
output:
2 2 2 2
result:
ok single line: '2 2 2 2 '
Test #2:
score: 0
Accepted
time: 28ms
memory: 3544kb
input:
64
output:
0 0 1 4
result:
ok single line: '0 0 1 4 '
Test #3:
score: 0
Accepted
time: 28ms
memory: 3604kb
input:
2023
output:
0 2 2 5
result:
ok single line: '0 2 2 5 '
Test #4:
score: 0
Accepted
time: 28ms
memory: 3616kb
input:
1560
output:
0 4 8 59
result:
ok single line: '0 4 8 59 '
Test #5:
score: 0
Accepted
time: 28ms
memory: 3596kb
input:
1625
output:
2 8 2 8
result:
ok single line: '2 8 2 8 '
Test #6:
score: 0
Accepted
time: 28ms
memory: 3552kb
input:
1888
output:
0 0 2 11
result:
ok single line: '0 0 2 11 '
Test #7:
score: 0
Accepted
time: 25ms
memory: 3604kb
input:
2125
output:
2 8 2 8
result:
ok single line: '2 8 2 8 '
Test #8:
score: 0
Accepted
time: 24ms
memory: 3608kb
input:
1950
output:
0 7 0 22
result:
ok single line: '0 7 0 22 '
Test #9:
score: 0
Accepted
time: 28ms
memory: 3504kb
input:
2477
output:
1 0 1 0
result:
ok single line: '1 0 1 0 '
Test #10:
score: 0
Accepted
time: 28ms
memory: 3600kb
input:
1728
output:
0 0 2 36
result:
ok single line: '0 0 2 36 '
Test #11:
score: 0
Accepted
time: 28ms
memory: 3584kb
input:
2249
output:
2 2 2 2
result:
ok single line: '2 2 2 2 '
Test #12:
score: 0
Accepted
time: 28ms
memory: 3804kb
input:
2176
output:
0 1 2 17
result:
ok single line: '0 1 2 17 '
Test #13:
score: 0
Accepted
time: 28ms
memory: 3516kb
input:
2467
output:
0 0 1 0
result:
ok single line: '0 0 1 0 '
Test #14:
score: 0
Accepted
time: 28ms
memory: 3604kb
input:
1898
output:
0 4 0 4
result:
ok single line: '0 4 0 4 '
Test #15:
score: 0
Accepted
time: 28ms
memory: 3596kb
input:
2048
output:
0 0 1 9
result:
ok single line: '0 0 1 9 '
Test #16:
score: 0
Accepted
time: 28ms
memory: 3532kb
input:
1875
output:
0 4 2 11
result:
ok single line: '0 4 2 11 '
Test #17:
score: 0
Accepted
time: 28ms
memory: 3600kb
input:
2187
output:
0 0 1 6
result:
ok single line: '0 0 1 6 '
Test #18:
score: 0
Accepted
time: 28ms
memory: 3532kb
input:
2431
output:
0 4 4 9
result:
ok single line: '0 4 4 9 '
Test #19:
score: 0
Accepted
time: 28ms
memory: 3608kb
input:
2028
output:
0 2 4 18
result:
ok single line: '0 2 4 18 '
Test #20:
score: 0
Accepted
time: 28ms
memory: 3812kb
input:
1105
output:
4 9 4 9
result:
ok single line: '4 9 4 9 '
Test #21:
score: 0
Accepted
time: 28ms
memory: 3752kb
input:
2210
output:
0 13 0 13
result:
ok single line: '0 13 0 13 '
Test #22:
score: 0
Accepted
time: 28ms
memory: 3548kb
input:
2465
output:
4 9 4 9
result:
ok single line: '4 9 4 9 '
Test #23:
score: 0
Accepted
time: 28ms
memory: 3560kb
input:
2187
output:
0 0 1 6
result:
ok single line: '0 0 1 6 '