Title description
Equation: a*a + b*b + c*c = 1000
Does this equation have a positive integer solution? There are: a,b,c=6,8,30 is a set of solutions.
Can you calculate another suitable solution?
Please fill in the smallest number in the solution.
Note: What you submit should be an integer, do not fill in any extra content or explanatory text.
Analysis: It's relatively simple, just direct violence, similar to the process of typing a meter:
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
for(int i=1;i<32;i++){
//32*32=1024
for(int j=i;j<32;j++){
for(int k=j;k<32;k++){
if(i*i+j*j+k*k==1000){
cout<<i<<' '<<j<<' '<<k<<endl;
}
}
}
}
return 0;
}
Output:
6 8 30
10 18 24
So the answer is 10