HDU1496
水题~~
题意:满足方程 a*x1*x1+b*x2*x2+c*x3*x3+d*x4*x4=0 的解的个数
直接模拟
三个for即可
View Code
1 #include<stdio.h> 2 #include<math.h> 3 int main(){ 4 int a,b,c,d; 5 while( scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF ){ 6 int ans=0; 7 if(( a>0&&b>0&&c>0&&d>0 )||( a<0&&b<0&&c<0&&d<0 )){ 8 printf("0\n"); 9 continue; 10 } 11 int tmp,tmp2; 12 for( int x1=1;x1<=100;x1++ ){ 13 for( int x2=1;x2<=100;x2++ ){ 14 for( int x3=1;x3<=100;x3++ ){ 15 tmp=a*x1*x1+b*x2*x2+c*x3*x3; 16 //if( tmp>( (-1)*d*10000 )) continue; 17 if( tmp%d==0 ) 18 tmp/=((-1)*d); 19 else 20 continue; 21 if( tmp<=0 ) continue; 22 tmp2=(int)sqrt(tmp*1.0); 23 if( tmp2*tmp2==tmp&&tmp2<=100&&tmp2>=1 ) 24 ans++; 25 } 26 } 27 } 28 printf("%d\n",16*ans); 29 } 30 return 0; 31 }
keep moving...