Problem Description
Lich Sandro investigates the magic of fire. He is standing in the center of a huge square hall with floor space one million square kilometers. The floor of the hall is paved with square 1 × 1 meter stone slabs. When Sandro waves his staff, a fire circle of radius R meters springs up around him. The center of the circle coincides with the center of the hall and is located at the point of contact of four slabs. Sandro wants to calculate the number of slabs damaged by the fire. A slab is assumed to be damaged if it has at least two common points with the fire circle. The figure shows as an example the slabs damaged by the fire circle of radius 4:

Input
The input file contains multiple cases. Proceed until End Of File.
Each case contains the radius of the fire circle R > 0. This is an integer not exceeding 105.
Output
Output the number of damaged slabs.
Sample Input
2
4
Sample Output
16
60
Hint:
Category: Geometry?
The max int value is about 2*10^9.
Such tip will never appear in formal Preliminary and Final games.
代码:
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
long long r;
while(~scanf("%lld",&r))
{
long long sum = 0;
long long r1 = r*r;
for(long long i=r-1;i>=0;i--)
{
long long r2 = r1-i*i;
double len = sqrt((double)r2);
sum+=(long long)ceil(len);
}
printf("%lld\n",sum*4);
}
}