Imagine you have an infinite 2D plane with Cartesian coordinate system. Some of the integral points are blocked, and others are not. Two integral points A and B on the plane are 4-connected if and only if:
- the Euclidean distance between A and B is one unit and neither A nor B is blocked;
- or there is some integral point C, such that A is 4-connected with C, and C is 4-connected with B.
Let's assume that the plane doesn't contain blocked points. Consider all the integral points of the plane whose Euclidean distance from the origin is no more than n, we'll name these points special. Chubby Yang wants to get the following property: no special point is 4-connected to some non-special point. To get the property she can pick some integral points of the plane and make them blocked. What is the minimum number of points she needs to pick?
The first line contains an integer n (0 ≤ n ≤ 4·107).
Print a single integer — the minimum number of points that should be blocked.
1
4
2
8
3
16
两个点是4-connected 需要满足以下条件
1,两点间的距离等于1,并且这两点的任意一个点都没有被blocked
2,或者如果A,B 4-connected,B,C 4-connected,那么A,C也4-connected。
定义特殊点为与坐标原点的距离不超过n的 整数点。
让你锁上一些点,使得任意特殊点不能和任意非特殊点相连。
求出锁得的最少的点。
没做出来- -
求两个圆间的点个数 。。。上大神代码 大神攻略- -
以下附两种方法- -
一: 非人类法
http://blog.csdn.net/polossk/article/details/19439855
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int n;
while (cin >> n){
int x = n * sqrt(double(2));
if (n == 0) cout << 1 << endl;
else cout << x * 4 << endl;
}
return 0;
}
二:
http://blog.csdn.net/rowanhaoa/article/details/19476011
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define LL __int64
LL dis(LL x,LL y)
{
return x*x+y*y;
}
int main()
{
LL n;
LL i,st;
while(~scanf("%I64d",&n))
{
if(n==0)
{
cout<<"1"<<endl;
continue;
}
LL sum=0;
st=n;
LL leap;
for(i=0;i<=n-1;i++)
{
leap=0;
while(n*n<dis(i+1,st))
{
sum++;
st--;
leap=1;
}
if(leap==0)
{
sum++;
}
}
cout<<sum*4<<endl;
}
return 0;
}
这个正常点- -