代码拉取完成,页面将自动刷新
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const int N = 5000010;
int h[N][3];
int n;
int main(int argc, char** argv) {
cin >> n;
for(int c = 0; c*c <= n; c++)
for(int d = c; d*d + c*c <= n; d++){
int tmp = d*d + c*c;
//哈希表中,当前位置没有数据才记录,倘若冲突了,也可以保证优先记录字典序较小的
if(h[tmp][0] == 0) {
h[tmp][0] = tmp;
h[tmp][1] = c;
h[tmp][2] = d;
}
}
for(int a = 0; a*a <= n; a++)
for(int b = a; b*b + a*a <= n; b++) {
int ans = n - a*a-b*b;
if(h[ans][0] != 0){
cout << a << " " << b << " " << h[ans][1] << " " << h[ans][2];
return 0;
}
}
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。