#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
int r, sum;
ld ox = 0.5, oy = 0.5;
ld dis(ld ax, ld ay, ld bx, ld by)
{
return sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));
}
int edge(int row)
{
if(row == 0)return 2*r-1;
int lft = 0, rgt = r;
while(lft < rgt)
{
int col = lft+rgt >> 1;
ld nx = row+1, ny = col+1;
if(dis(ox, oy, nx, ny)-r > 0.000000001)rgt = col-1;
else lft = col+1;
}
return lft;
}
signed main()
{
cin >> r;
for(int i = 0;i <= r-1;i++)
if(edge(i) == 0)sum += 2;
else sum += 2*edge(i)-1;
cout << sum;
return 0;
}
是这样吗?有什么问题?