You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
878 B
39 lines
878 B
2 years ago
|
#include <cstdio>
|
||
|
#include <cstring>
|
||
|
#include <algorithm>
|
||
|
#include <cmath>
|
||
|
/*
|
||
|
用桶计数的思路
|
||
|
*/
|
||
|
// Accepted 134 ms
|
||
|
using namespace std;
|
||
|
const int N = 5e6 + 10;
|
||
|
int n;
|
||
|
int bucket[N];
|
||
|
|
||
|
int main() {
|
||
|
scanf("%d", &n);
|
||
|
|
||
|
memset(bucket, -1, sizeof bucket);
|
||
|
|
||
|
for (int c = 0; c * c <= n / 2; c++)
|
||
|
for (int d = c; c * c + d * d <= n; d++) {
|
||
|
int t = c * c + d * d;
|
||
|
if (t > 5e6) continue;
|
||
|
if (bucket[t] == -1) bucket[t] = c;
|
||
|
}
|
||
|
|
||
|
for (int a = 0; a * a <= n / 4; a++) {
|
||
|
for (int b = a; a * a + b * b <= n / 3; b++) {
|
||
|
int t = n - a * a - b * b;
|
||
|
int c = bucket[t];
|
||
|
if (c == -1 || t > 5e6) continue;
|
||
|
int d = sqrt(t - c * c);
|
||
|
printf("%d %d %d %d\n", a, b, c, d);
|
||
|
exit(0);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|