QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#325953#5676. Counting Pythagorean TriplescryAC ✓76ms3820kbC++202.3kb2024-02-12 05:31:262024-02-12 05:31:26

Judging History

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

  • [2024-02-12 05:31:26]
  • 评测
  • 测评结果:AC
  • 用时:76ms
  • 内存:3820kb
  • [2024-02-12 05:31:26]
  • 提交

answer

#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#ifndef LOCAL
#define debug(...) 0
#else
#include "C:\programmingfunnyxd\debug.cpp"
#endif
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFLL = 1e18;
 
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FORE(i,a,b) for(int i = (a); i <= (b); ++i)
#define ROF(i,a,b) for(int i = (a); i >= (b); --i)
#define trav(a,x) for(auto& a: x)
#define sz(x) (int)x.size()
#define make_unique(v) sort(all(v)); v.erase(unique(all(v)), v.end())

template<class T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<class T> bool ckmin(T& a, const T& b){return b<a?a=b,1:0;}
template<class T> bool ckmax(T& a, const T& b){return a<b?a=b,1:0;}
template<int D, typename T>struct vt : public vector<vt<D - 1, T>> { template<typename... Args>
	vt(int n = 0, Args... args) : vector<vt<D - 1, T>>(n, vt<D - 1, T>(args...)) {}};
template<typename T> struct vt<1, T> : public vector<T> {
	vt(int n = 0, const T& val = T()) : vector<T>(n, val) {}};
template<typename T> istream& operator>>(istream& in, vector<T>& a) {for(auto &x : a) in >> x; return in;};
template<typename T> ostream& operator<<(ostream& out, vector<T>& a) {for(auto &x : a) out << x << ' '; return out;};

const int N = 2501;

void solve() {
	int n; cin >> n;
	vector<int> ans(4);
	FOR(i,1,N){
		FOR(j,i,N){
			ll k = (ll)i * i + (ll)j * j;
			if(ceil(sqrtl(k)) == floor(sqrtl(k))){
				k = sqrtl(k);
				ll g = gcd(i, gcd(j, k));
				if(k == n){
					debug(i, j, k);
					if(g == 1) ans[0]++;
					if(g != 1) ans[1]++;
				}
				// if(i == n || j == n){
					// if(g == 1) ans[2]++;
					// if(g != 1) ans[3]++;
				// }
			}
		}
	}
	FOR(i,1,N * N){
		ll k = (ll) i * i + (ll) n * n;
		if(ceil(sqrt(k)) == floor(sqrtl(k))){
			int g = gcd(i, gcd(n, (ll)sqrtl(k)));
			if(g == 1) ans[2]++;
			if(g != 1) ans[3]++;
		}
	}
	cout << ans << endl;
}

signed main() {
	cin.tie(0) -> sync_with_stdio(0);
	int t = 1;
	//cin >> t;
	for(int test = 1; test <= t; test++){
		solve();
	}
}

/*   /\_/\
*   (= ._.)
*   / >  \>
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 59ms
memory: 3528kb

input:

65

output:

2 2 2 2 

result:

ok single line: '2 2 2 2 '

Test #2:

score: 0
Accepted
time: 63ms
memory: 3760kb

input:

64

output:

0 0 1 4 

result:

ok single line: '0 0 1 4 '

Test #3:

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

input:

2023

output:

0 2 2 5 

result:

ok single line: '0 2 2 5 '

Test #4:

score: 0
Accepted
time: 63ms
memory: 3804kb

input:

1560

output:

0 4 8 59 

result:

ok single line: '0 4 8 59 '

Test #5:

score: 0
Accepted
time: 63ms
memory: 3492kb

input:

1625

output:

2 8 2 8 

result:

ok single line: '2 8 2 8 '

Test #6:

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

input:

1888

output:

0 0 2 11 

result:

ok single line: '0 0 2 11 '

Test #7:

score: 0
Accepted
time: 56ms
memory: 3744kb

input:

2125

output:

2 8 2 8 

result:

ok single line: '2 8 2 8 '

Test #8:

score: 0
Accepted
time: 63ms
memory: 3752kb

input:

1950

output:

0 7 0 22 

result:

ok single line: '0 7 0 22 '

Test #9:

score: 0
Accepted
time: 63ms
memory: 3744kb

input:

2477

output:

1 0 1 0 

result:

ok single line: '1 0 1 0 '

Test #10:

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

input:

1728

output:

0 0 2 36 

result:

ok single line: '0 0 2 36 '

Test #11:

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

input:

2249

output:

2 2 2 2 

result:

ok single line: '2 2 2 2 '

Test #12:

score: 0
Accepted
time: 65ms
memory: 3820kb

input:

2176

output:

0 1 2 17 

result:

ok single line: '0 1 2 17 '

Test #13:

score: 0
Accepted
time: 59ms
memory: 3800kb

input:

2467

output:

0 0 1 0 

result:

ok single line: '0 0 1 0 '

Test #14:

score: 0
Accepted
time: 69ms
memory: 3764kb

input:

1898

output:

0 4 0 4 

result:

ok single line: '0 4 0 4 '

Test #15:

score: 0
Accepted
time: 64ms
memory: 3608kb

input:

2048

output:

0 0 1 9 

result:

ok single line: '0 0 1 9 '

Test #16:

score: 0
Accepted
time: 63ms
memory: 3484kb

input:

1875

output:

0 4 2 11 

result:

ok single line: '0 4 2 11 '

Test #17:

score: 0
Accepted
time: 63ms
memory: 3524kb

input:

2187

output:

0 0 1 6 

result:

ok single line: '0 0 1 6 '

Test #18:

score: 0
Accepted
time: 59ms
memory: 3616kb

input:

2431

output:

0 4 4 9 

result:

ok single line: '0 4 4 9 '

Test #19:

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

input:

2028

output:

0 2 4 18 

result:

ok single line: '0 2 4 18 '

Test #20:

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

input:

1105

output:

4 9 4 9 

result:

ok single line: '4 9 4 9 '

Test #21:

score: 0
Accepted
time: 63ms
memory: 3608kb

input:

2210

output:

0 13 0 13 

result:

ok single line: '0 13 0 13 '

Test #22:

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

input:

2465

output:

4 9 4 9 

result:

ok single line: '4 9 4 9 '

Test #23:

score: 0
Accepted
time: 67ms
memory: 3616kb

input:

2187

output:

0 0 1 6 

result:

ok single line: '0 0 1 6 '