QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#744843 | #5676. Counting Pythagorean Triples | MattTheNub# | AC ✓ | 2ms | 3704kb | C++23 | 2.4kb | 2024-11-13 23:49:03 | 2024-11-13 23:49:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T> using v = vector<T>;
using ll = long long;
using dd = long double;
using int2 = pair<int, int>;
using ll2 = pair<ll, ll>;
using dd2 = pair<dd, dd>;
#define f first
#define s second
#define all(x) begin(x), end(x)
istream &__cin = cin;
#ifdef DEV_MODE
#include "debug.h"
__cinwrapper __cin_wrapper;
#define cin __cin_wrapper
#else
#define dbg(...)
#define dbg2d(...)
#endif
template <class T1, class T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
in >> p.first >> p.second;
return in;
}
template <class T> istream &operator>>(istream &in, v<T> &v) {
for (auto &x : v)
in >> x;
return in;
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*
_______________________________________
( If you don't fail at least 90% of the )
( time, you're not aiming high enough. )
( )
( - Alan Kay )
---------------------------------------
o ^__^
o (oo)\_______
(__)\ )\/\
||----w |
|| ||
*/
const bool INTERACTIVE = false;
const bool MULTITEST = false;
/******************************************************************************/
#pragma region templates
#pragma endregion templates
void solve() {
int n;
cin >> n;
int pc = 0, npc = 0, pa = 0, npa = 0;
for (int a = 1; a < n; a++) {
for (int b = a; b < n; b++) {
if (a * a + b * b == n * n) {
if (gcd(gcd(a, b), n) == 1)
pc++;
else
npc++;
}
}
}
for (int i = 1; i <= n; i++) {
if (n * n % i == 0) {
int diff = (n * n) / i - i;
if (diff > 0 && !(diff & 1)) {
int b = diff / 2;
int c = i + b;
if (gcd(gcd(b, c), n) == 1)
pa++;
else
npa++;
}
}
}
cout << pc << ' ' << npc << ' ' << pa << ' ' << npa;
}
int main() {
#ifdef DEV_MODE
debug_start(INTERACTIVE, "d.txt");
#else
ios::sync_with_stdio(false);
cin.tie(nullptr);
#endif
int t;
if (MULTITEST)
cin >> t;
else
t = 1;
while (t--)
solve();
#ifdef DEV_MODE
debug_exit(INTERACTIVE);
#endif
}
#ifdef DEV_MODE
#include "debug.cpp"
#endif
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
65
output:
2 2 2 2
result:
ok single line: '2 2 2 2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
64
output:
0 0 1 4
result:
ok single line: '0 0 1 4'
Test #3:
score: 0
Accepted
time: 2ms
memory: 3568kb
input:
2023
output:
0 2 2 5
result:
ok single line: '0 2 2 5'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3612kb
input:
1560
output:
0 4 8 59
result:
ok single line: '0 4 8 59'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3688kb
input:
1625
output:
2 8 2 8
result:
ok single line: '2 8 2 8'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
1888
output:
0 0 2 11
result:
ok single line: '0 0 2 11'
Test #7:
score: 0
Accepted
time: 2ms
memory: 3704kb
input:
2125
output:
2 8 2 8
result:
ok single line: '2 8 2 8'
Test #8:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
1950
output:
0 7 0 22
result:
ok single line: '0 7 0 22'
Test #9:
score: 0
Accepted
time: 2ms
memory: 3688kb
input:
2477
output:
1 0 1 0
result:
ok single line: '1 0 1 0'
Test #10:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
1728
output:
0 0 2 36
result:
ok single line: '0 0 2 36'
Test #11:
score: 0
Accepted
time: 2ms
memory: 3704kb
input:
2249
output:
2 2 2 2
result:
ok single line: '2 2 2 2'
Test #12:
score: 0
Accepted
time: 2ms
memory: 3700kb
input:
2176
output:
0 1 2 17
result:
ok single line: '0 1 2 17'
Test #13:
score: 0
Accepted
time: 2ms
memory: 3640kb
input:
2467
output:
0 0 1 0
result:
ok single line: '0 0 1 0'
Test #14:
score: 0
Accepted
time: 1ms
memory: 3604kb
input:
1898
output:
0 4 0 4
result:
ok single line: '0 4 0 4'
Test #15:
score: 0
Accepted
time: 2ms
memory: 3620kb
input:
2048
output:
0 0 1 9
result:
ok single line: '0 0 1 9'
Test #16:
score: 0
Accepted
time: 1ms
memory: 3692kb
input:
1875
output:
0 4 2 11
result:
ok single line: '0 4 2 11'
Test #17:
score: 0
Accepted
time: 2ms
memory: 3692kb
input:
2187
output:
0 0 1 6
result:
ok single line: '0 0 1 6'
Test #18:
score: 0
Accepted
time: 2ms
memory: 3688kb
input:
2431
output:
0 4 4 9
result:
ok single line: '0 4 4 9'
Test #19:
score: 0
Accepted
time: 2ms
memory: 3616kb
input:
2028
output:
0 2 4 18
result:
ok single line: '0 2 4 18'
Test #20:
score: 0
Accepted
time: 1ms
memory: 3672kb
input:
1105
output:
4 9 4 9
result:
ok single line: '4 9 4 9'
Test #21:
score: 0
Accepted
time: 2ms
memory: 3700kb
input:
2210
output:
0 13 0 13
result:
ok single line: '0 13 0 13'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
2465
output:
4 9 4 9
result:
ok single line: '4 9 4 9'
Test #23:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
2187
output:
0 0 1 6
result:
ok single line: '0 0 1 6'