HDU 3835R(N)(加点思维的暴力枚举)R(N)Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768
HDU 3835R(N)(加点思维的暴力枚举)
HDU 3835R(N)(加点思维的暴力枚举)
26102565
4081216HintFor 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)
#include<iostream>#include<cstring>#include<string>#include<cstdio>#include<cmath>using namespace std;int main(){ int n,i,a,b,ma,res; while(~scanf("%d",&n)) { ma=sqrt(double(n)); //最大的a,a>b>=0 res=0; for(a=1;a<=ma;a++) { b=sqrt(double(n-a*a)); if(a*a+b*b==n) res+=4; //a,b;a,-b;-a,b;-a,-b; } cout<<res<<endl; } return 0;}//46MS 280K