//4359928 2011-08-08 13:40:09 Accepted 3835 31MS 176K 526 B C ylwh!
#include <stdio.h>
#include <math.h>
int main()
{
int n, i, j, counts, p, q;
while(scanf("%d", &n) != EOF)
{
if(n == 0)
{
printf("1\n");
continue;
}
p = q = counts = 0;
for(i=0; i<=(int) ( sqrt( (double) (n / 2.0 ) ) ); i++)
{
j = ( int )sqrt( (double) ( n - i*i) );
if(i * i + j* j != n)
continue;
counts++;
if(i == 0)
p = 1;
else if(i == j)
q = 1;
}
if(p) counts--;
if(q) counts--;
printf("%d\n", counts*8 + (p+q)*4 );
}
return 0;
}
HDOJ 3835 R(N)
最新推荐文章于 2022-07-02 16:12:16 发布