QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#179248 | #5676. Counting Pythagorean Triples | wdbl857 | AC ✓ | 23ms | 3728kb | C++20 | 1.5kb | 2023-09-14 19:56:15 | 2023-09-14 19:56:15 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define int long long
#define endl "\n"
#define pi acos(-1)
typedef pair<int, int> PII;
typedef pair<int, PII> PIII;
const int N = 1e6 + 10, M = 1010, INF = 0x3f3f3f3f, mod = 998244353;
set<PII> s;
vector<PII> d;
int n;
int a, b, c, e;
int check(int x)
{
int a = sqrt(x);
if (a * a == x)
return 1;
return 0;
}
int asd(int x, int y, int z)
{
int u = __gcd(x, y);
int v = __gcd(y, z);
if (__gcd(u, v) == 1)
return 1;
return 0;
}
void solve()
{
cin >> n;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= n; j++)
{
if (i * i + j * j == n * n)
{
if (i > j)
s.insert({j, i});
else
s.insert({i, j});
}
}
}
for (int i = 1; i <= N*10; i++)
{
if (check(i * i + n * n))
d.push_back({i, sqrt(i * i + n * n)});
}
for (auto [x, y] : s)
{
if (asd(x, y, n))
a++;
else
b++;
}
for (auto [x, y] : d)
{
if (asd(x, n, y))
c++;
else
e++;
}
cout << a << ' ' << b << ' ' << c << ' ' << e << endl;
}
signed main()
{
ios;
int T = 1;
// cin >> T;
while (T--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 18ms
memory: 3724kb
input:
65
output:
2 2 2 2
result:
ok single line: '2 2 2 2'
Test #2:
score: 0
Accepted
time: 18ms
memory: 3652kb
input:
64
output:
0 0 1 4
result:
ok single line: '0 0 1 4'
Test #3:
score: 0
Accepted
time: 21ms
memory: 3584kb
input:
2023
output:
0 2 2 5
result:
ok single line: '0 2 2 5'
Test #4:
score: 0
Accepted
time: 20ms
memory: 3652kb
input:
1560
output:
0 4 8 59
result:
ok single line: '0 4 8 59'
Test #5:
score: 0
Accepted
time: 16ms
memory: 3652kb
input:
1625
output:
2 8 2 8
result:
ok single line: '2 8 2 8'
Test #6:
score: 0
Accepted
time: 21ms
memory: 3608kb
input:
1888
output:
0 0 2 11
result:
ok single line: '0 0 2 11'
Test #7:
score: 0
Accepted
time: 22ms
memory: 3648kb
input:
2125
output:
2 8 2 8
result:
ok single line: '2 8 2 8'
Test #8:
score: 0
Accepted
time: 17ms
memory: 3612kb
input:
1950
output:
0 7 0 22
result:
ok single line: '0 7 0 22'
Test #9:
score: 0
Accepted
time: 23ms
memory: 3668kb
input:
2477
output:
1 0 1 0
result:
ok single line: '1 0 1 0'
Test #10:
score: 0
Accepted
time: 21ms
memory: 3588kb
input:
1728
output:
0 0 2 36
result:
ok single line: '0 0 2 36'
Test #11:
score: 0
Accepted
time: 22ms
memory: 3656kb
input:
2249
output:
2 2 2 2
result:
ok single line: '2 2 2 2'
Test #12:
score: 0
Accepted
time: 22ms
memory: 3728kb
input:
2176
output:
0 1 2 17
result:
ok single line: '0 1 2 17'
Test #13:
score: 0
Accepted
time: 23ms
memory: 3696kb
input:
2467
output:
0 0 1 0
result:
ok single line: '0 0 1 0'
Test #14:
score: 0
Accepted
time: 21ms
memory: 3664kb
input:
1898
output:
0 4 0 4
result:
ok single line: '0 4 0 4'
Test #15:
score: 0
Accepted
time: 21ms
memory: 3728kb
input:
2048
output:
0 0 1 9
result:
ok single line: '0 0 1 9'
Test #16:
score: 0
Accepted
time: 21ms
memory: 3664kb
input:
1875
output:
0 4 2 11
result:
ok single line: '0 4 2 11'
Test #17:
score: 0
Accepted
time: 22ms
memory: 3652kb
input:
2187
output:
0 0 1 6
result:
ok single line: '0 0 1 6'
Test #18:
score: 0
Accepted
time: 23ms
memory: 3612kb
input:
2431
output:
0 4 4 9
result:
ok single line: '0 4 4 9'
Test #19:
score: 0
Accepted
time: 21ms
memory: 3644kb
input:
2028
output:
0 2 4 18
result:
ok single line: '0 2 4 18'
Test #20:
score: 0
Accepted
time: 19ms
memory: 3668kb
input:
1105
output:
4 9 4 9
result:
ok single line: '4 9 4 9'
Test #21:
score: 0
Accepted
time: 18ms
memory: 3652kb
input:
2210
output:
0 13 0 13
result:
ok single line: '0 13 0 13'
Test #22:
score: 0
Accepted
time: 23ms
memory: 3584kb
input:
2465
output:
4 9 4 9
result:
ok single line: '4 9 4 9'
Test #23:
score: 0
Accepted
time: 22ms
memory: 3652kb
input:
2187
output:
0 0 1 6
result:
ok single line: '0 0 1 6'