是的这个人偏爱数学题,虽然打得很菜只出了五题也还是只把M拉出来单写了个题解。
啊矩阵?矩阵不存在日更的这辈子都不会日更的。
题目描述:
PUBG is a multiplayer online battle royale video game. In the game, up to one hundred players parachute onto an island and scavenge for weapons and equipment to kill others while avoiding getting killed themselves. BaoBao is a big fan of the game, but this time he is having some trouble selecting the safest building.
There are n buildings scattering on the island in the game, and we consider these buildings as points on a two-dimensional plane. At the beginning of each round, a circular safe area whose center is located at (0, 0) with radius R will be spawned on the island. After some time, the safe area will shrink down towards a random circle with radius r(r ≤ R). The whole new safe area is entirely contained in the original safe area (may be tangent to the original safe area), and the center of the new safe area is uniformly chosen within the original safe area.
The buildings covered by the new safe area is called the safe buildings. Given the radius of the safe areas and the positions of the buildings, BaoBao wants to find all the buildings with the largest probability to become safe buildings.
输入描述:
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case:
The first line contains three integers n (1 ≤ n ≤ 100),R and r(1 ≤ r ≤ R ≤ 104) , indicating the number of buildings and the radius of two safe circles.
The following n lines each contains 2 integers xi and yi (−104 ≤ xi,yi ≤ 104) ,indicating the coordinate of the buildings. Here we assume that the center of the original safe circle is located at (0,0) , and all the buildings are inside the original circle.
It’s guaranteed that the sum of n over all test cases will not exceed 5000.
输出描述:
For each test case output two lines.
The first line contains an integer m, indicating the number of buildings with the highest probability to become safe buildings.
The second line contains m integers separated by a space in ascending order, indicating the indices of safest buildings.
Please, DO NOT output extra spaces at the end of each line.
大概意思就是有一个以原点为圆心的大圆,半径为R,大圆里面有一个半径为r的小圆。然后给你一系列点问你哪些点在小圆里面的可能性最大。
首先大概想法,小圆的圆心可能在哪?当然是以原点为圆心,R-r为半径的圆里。然后你判断一个点在不在小圆里,你要以这个点为圆心,r为半径画圆,只要圆心在这个范围内,这个点都在小圆内部。
然后问题来了,如果你要判断的点在以原点为圆心,半径分别为R-2r的圆里,那这些点在小圆内部的可能是相等的,可能性都是(πr^2)/(π*(R-r)^2),但是如果你要判断的点在半径R-2r的圆外,你画个圆发现圆里有一部分点是小圆圆心取不到的,它超出了半径为R-r的圆的范围。
所以你得出,在R>2r的情况下,在以原点为圆心,R-2r为半径的圆内,点在小圆范围内的可能是最大并且相等的。出了这个范围的点离原点越远可能越小。
R=2r的情况其实是包含在上述情况内的,就是原点可能最大,然后离原点越远可能性越小嘛。
在但是如果2r>R,那就是以2r-R为半径的圆内可能性最大并且相等,圆外的点距离原点越远可能性越小。
当R=r时,小圆的圆心只能在原点,即圆内所有点都是等可能并且一定在小圆内的。
……然后题也就这样了。
下面ac代码。
#include
#include
#include
#include
#include
using namespace std;
int main(){
int T;
vector<int>vec;
while(scanf("%d",&T)!=EOF){
while(T--){
vec.clear();
int n;
double R,r,x,y,minn=20000,edge;
scanf("%d%lf%lf",&n,&R,&r);
if(R-2*r>0) edge=R-2*r;
else if(R==2*r) edge=0;
else edge=2*r-R;
int sum=0,flag=0;
for(int i=1;i<=n;i++){
scanf("%lf%lf",&x,&y);
double len=sqrt(x*x+y*y);
if(flag==0){
if(len<=edge){
flag=1;
vec.clear();
vec.push_back(i);
continue;
}
if(lenvec.clear();
vec.push_back(i);
}
else if(len==minn)
vec.push_back(i);
}
else{
if(len<=edge)
vec.push_back(i);
}
}
int k=vec.size(),num=0;
printf("%d\n",k);
for(int i=0;iprintf("%d%c",vec[i],(i==k-1) ? '\n':' ');
}
}
return 0;
}
(其实是组队赛我推出来公式看别的题去了代码是队友写的)
(推一下队友的博客,溜了http://my.csdn.net/stupid_turtle)
(以上)