标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 14886 Accepted Submission(s):
4890
1 #include <iostream> 2 #include <cstdio> 3 #include <cmath> 4 using namespace std; 5 int main() 6 { 7 int x,y,num,i,flag=0,temp; 8 double z; 9 while(scanf("%d",&num)!=EOF) 10 { 11 flag=0; 12 for(x=1;x<=sqrt(num);x++) 13 { 14 for(y=1;y<=sqrt(num-x*x);y++) 15 { 16 temp=num-x*x-y*y; 17 z=sqrt(temp); /*求平方根*/ 18 if(abs(z-int(z))<=0.000001&&int(z)) /*判断平方根是否为整数*/ 19 { 20 printf("%d %d %d\n",x,y,int(z)); 21 flag=1; 22 break; 23 } 24 } 25 if(flag) 26 break; 27 } 28 } 29 }
标签:
原文地址:http://www.cnblogs.com/a1225234/p/4690431.html