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.

34 lines
839 B

#include <cstdio>
#include <cstring>
#include <unordered_map>
using namespace std;
typedef pair<int, int> PII;
#define x first
#define y second
// TLE
// 通过了 8/11个数据
unordered_map<int, PII> _map;
int main() {
int n;
scanf("%d", &n);
for (int c = 0; c * c <= n; c++)
for (int d = c; d * d + c * c <= n; d++) {
int t = c * c + d * d;
if (t > 5e6) continue;
if (_map.count(t) == 0) _map[t] = {c, d};
}
for (int a = 0; a * a <= n; a++)
for (int b = a; b * b + a * a <= n; b++) {
int t = n - a * a - b * b;
if (t > 5e6) continue;
if (_map.count(t)) {
printf("%d %d %d %d", a, b, _map[t].x, _map[t].y);
return 0;
}
}
return 0;
}