完美立方
2017-08-06 17:04
225 查看
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
for(int a=2;a<=n;a++)
for(int b=2;b<a;b++)
for(int c=b;c<a;c++)
for(int d=c;d<a;d++)
{
int e=d*d*d+b*b*b+c*c*c;
if(a*a*a==e)
cout<<"Cube = "<<a<<", Triple = ("<<b<<","<<c<<","<<d<<")"<<endl;
}
return 0;
}
using namespace std;
int main()
{
int n;
cin>>n;
for(int a=2;a<=n;a++)
for(int b=2;b<a;b++)
for(int c=b;c<a;c++)
for(int d=c;d<a;d++)
{
int e=d*d*d+b*b*b+c*c*c;
if(a*a*a==e)
cout<<"Cube = "<<a<<", Triple = ("<<b<<","<<c<<","<<d<<")"<<endl;
}
return 0;
}