hdu 3835 R(N)
Hint
For the fourth test case, (A,B) can be (0,5), (0,-5), (5,0), (-5,0), (3,4), (3,-4), (-3,4), (-3,-4), (4,3) , (4,-3), (-4,3), (-4,-3)
Source
2011 Multi-University Training Contest 1 - Host by HNU
Recommend
xubiao
1 //31MS 280K 439 B C++ 2 //简单题..O(lgn) 3 #include<stdio.h> 4 #include<math.h> 5 int Pow(int n) 6 { 7 return n*n; 8 } 9 int main(void) 10 { 11 int n; 12 while(scanf("%d",&n)!=EOF) 13 { 14 int i=0; 15 int ans=0; 16 while(i*i<=n){ 17 if(Pow((int)(sqrt((n-i*i)*1.0)))==(n-i*i)){ 18 if(i==0 || n-i*i==0) ans+=2; 19 else ans+=4; 20 } 21 i++; 22 } 23 printf("%d\n",ans); 24 } 25 return 0; 26 }