目录
LEYNI, LOLI AND CIRCLE

** LEYNI, LOLI AND CIRCLE:** <Excerpt in index | 首页摘要>

<The rest of contents | 余下全文>

Leyni, LOLI and Circle
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 156(56 users) Total Accepted: 68(50 users) Rating: Special Judge: No
Description
Professor Leyni likes to play with LOLIs. This time, Leyni meets several LOLIs on the playground and begins to play game with them. At the beginning, he makes N LOLIs around the playground and numbers them in clockwise order and the LOLIs are so obedient that they run clockwise under the guide of Leyni on the boundary of the playground which is a circle. At first, the distance of each pair of adjacent LOLIs are the same around the boundary of the circle. When one LOLI catches up with its previous one, the game is over. Knowing the speed of each LOLI, Leyni asks you to help him to change the order of the LOLIs to make him be able to play with them longer.

Input
There are multiple test cases. The first line of input is an integer T indicating the number of test cases. Then T test cases follow. For each test case: Line 1. Two numbers N (N <= 5000) and R(1 <= R <= 100000), representing the number of LOLIs and the radius of the circle. Line 2. This line contains N integers and the i-th number is the speed of the i-th LOLI in clockwise direction. All these N numbers are in the range [1, 1000].

Output
For each test case: Line 1. If the Leyni can play with them forever, output “LeyniV5!”, otherwise output the longest time the game can last, which should be accurately rounded to three decimals.

Sample Input
2 3 1 1 1 1 2 1 1 2

Sample Output
LeyniV5! 3.142

Author
哈理工2011春季校赛
其实就是排个序,让a[0]追a[1],a[1]追a[2]以此类推

无奈我智商太低看的别人的代码

Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include<iostream>
#include<cmath>
#include<stdio.h>
#include<algorithm>
using namespace std;
double PI=atan(1.0)*4;
double a[5000];
int main()
{
int T;
double r;
int n;
while(~scanf("%d",&T))
{
while(T--)
{
scanf("%d%lf",&n,&r);
int i;
double h=PI*2*r/n;
for(i=0;i<n;i++)
{
scanf("%lf",&a[i]);
}
sort(a,a+n);
if(a[0]==a[n-1])
{
printf("LeyniV5!\n");
}
else
{
double max=-100000;
for(i=n-1;i>=1;i--)
{
if(a[i]-a[i-1]>max)
{
max=a[i]-a[i-1];
}
}
// cout<<h<<endl;
// cout<<max<<endl;
printf("%.3lf\n",h/max);
}
}
}
return 0;
}
文章作者: 爱笑的k11
文章链接: http://1315402725.github.io/posts/e0374175/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 爱笑的k11
打赏
  • 微信
  • 支付寶

评论