QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#714691#5676. Counting Pythagorean Tripleszeyu#AC ✓16ms3768kbC++232.3kb2024-11-06 02:35:012024-11-06 02:35:04

Judging History

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

  • [2024-11-06 02:35:04]
  • 评测
  • 测评结果:AC
  • 用时:16ms
  • 内存:3768kb
  • [2024-11-06 02:35:01]
  • 提交

answer

#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define pl pair<ll, ll>
#define pi pair<int, int>
#define minpq priority_queue<ll, vector<ll>, greater<ll>>
using namespace std;

#if 1
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '['; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "]";}
void _print() {cerr << endl << flush;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "*["<<__LINE__<<"]\t"<< #x << " = "; _print(x)
#endif

const ll mod = 1e9 + 7;

template<typename T> bool chkmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chkmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
ll gcd(ll a, ll b) {if(b == 0){return a;} return gcd(b, a % b);}

bool issq(ll x){
	ll y = floor(sqrt(x));
	if (y * y == x || (y + 1) * (y + 1) == x) return true;
	return false;
}

ll getsq(ll x){
	ll y = floor(sqrt(x));
	if (y * y == x) return y;
	return y + 1;
}

int ans[4];
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n; cin >> n;
	for (ll i = 1; i < n; i ++){
		if (issq(n * n - i * i)){
			ll j = getsq(n * n - i * i);
			if (j > i) continue;
			if (gcd(gcd(i, j), n) == 1){
				ans[0] ++;
			} else{
				ans[1] ++;
			}
		}
	}
	for (ll i = 1; i < n * n; i ++){
		if (issq(n * n + i * i)){
			ll j = getsq(n * n + i * i);
			if (gcd(gcd(i, j), n) == 1){
				ans[2] ++;
			} else{
				ans[3] ++;
			}
		}
	}
	for (int i = 0; i < 4; i ++) cout << ans[i] << ' ';
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3768kb

input:

65

output:

2 2 2 2 

result:

ok single line: '2 2 2 2 '

Test #2:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

64

output:

0 0 1 4 

result:

ok single line: '0 0 1 4 '

Test #3:

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

input:

2023

output:

0 2 2 5 

result:

ok single line: '0 2 2 5 '

Test #4:

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

input:

1560

output:

0 4 8 59 

result:

ok single line: '0 4 8 59 '

Test #5:

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

input:

1625

output:

2 8 2 8 

result:

ok single line: '2 8 2 8 '

Test #6:

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

input:

1888

output:

0 0 2 11 

result:

ok single line: '0 0 2 11 '

Test #7:

score: 0
Accepted
time: 13ms
memory: 3712kb

input:

2125

output:

2 8 2 8 

result:

ok single line: '2 8 2 8 '

Test #8:

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

input:

1950

output:

0 7 0 22 

result:

ok single line: '0 7 0 22 '

Test #9:

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

input:

2477

output:

1 0 1 0 

result:

ok single line: '1 0 1 0 '

Test #10:

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

input:

1728

output:

0 0 2 36 

result:

ok single line: '0 0 2 36 '

Test #11:

score: 0
Accepted
time: 14ms
memory: 3724kb

input:

2249

output:

2 2 2 2 

result:

ok single line: '2 2 2 2 '

Test #12:

score: 0
Accepted
time: 13ms
memory: 3700kb

input:

2176

output:

0 1 2 17 

result:

ok single line: '0 1 2 17 '

Test #13:

score: 0
Accepted
time: 16ms
memory: 3568kb

input:

2467

output:

0 0 1 0 

result:

ok single line: '0 0 1 0 '

Test #14:

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

input:

1898

output:

0 4 0 4 

result:

ok single line: '0 4 0 4 '

Test #15:

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

input:

2048

output:

0 0 1 9 

result:

ok single line: '0 0 1 9 '

Test #16:

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

input:

1875

output:

0 4 2 11 

result:

ok single line: '0 4 2 11 '

Test #17:

score: 0
Accepted
time: 13ms
memory: 3632kb

input:

2187

output:

0 0 1 6 

result:

ok single line: '0 0 1 6 '

Test #18:

score: 0
Accepted
time: 16ms
memory: 3660kb

input:

2431

output:

0 4 4 9 

result:

ok single line: '0 4 4 9 '

Test #19:

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

input:

2028

output:

0 2 4 18 

result:

ok single line: '0 2 4 18 '

Test #20:

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

input:

1105

output:

4 9 4 9 

result:

ok single line: '4 9 4 9 '

Test #21:

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

input:

2210

output:

0 13 0 13 

result:

ok single line: '0 13 0 13 '

Test #22:

score: 0
Accepted
time: 16ms
memory: 3696kb

input:

2465

output:

4 9 4 9 

result:

ok single line: '4 9 4 9 '

Test #23:

score: 0
Accepted
time: 13ms
memory: 3680kb

input:

2187

output:

0 0 1 6 

result:

ok single line: '0 0 1 6 '