#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int N;
int a, b, c, d;
scanf("%d", &N);
for (a = 3; a <= N; a ++){
for (b = 2; b < a; b ++){
for (c = b; c <= a; c++){
for (d = c; d <= a; d++){
if (a*a*a == (b*b*b + c*c*c + d*d*d)){
printf("Cube = %d, Triple = (%d,%d,%d)\n", a, b, c, d);
}
}
}
}
}
return 0;
}
【Openjudge, NOI, 枚举】1812完美立方
最新推荐文章于 2024-03-16 22:47:39 发布
本文介绍了一个C++程序,该程序通过四层循环遍历指定范围内的整数,寻找满足a³=b³+c³+d³的整数解,并打印出所有找到的立方和及其对应的三元组。


4279

被折叠的 条评论
为什么被折叠?



