ants run 题意理解
来源:互联网 发布:asp 网页访问数据库 编辑:程序博客网 时间:2024/05/22 12:07
Professor Yang likes to play with ants when he is free. What? Are you asking why he plays with ants instead of others? Ah, because ant is the only non-plant living thing which can be found in Qingshuihe Campus of UESTC apart from human beings.
This time, Professor Yang caught several ants after finishing his lecture for freshmen. At the beginning of the game, he puts NN ants around a plate and numbers them in clockwise order. The ants are so obedient that they run clockwise under the guide of Professor Yang on the boundary of the plate which is a circle. When one ant catches up with its previous ant, the game is over. Knowing the speed of ants, Professor Yang wants you to help him to adjust the distance between adjacent ants to make the game last longer.
Input
The first line of the input is TT (no more than 1000010000), which stands for the number of test cases you need to solve.
Each test case begins with N R representing the number of ants participating the game is NN and the radius of the circle is RR cm. The next line lists NN integers and the ithith number is the speed (cm/s) of the ii-th ant in clockwise direction. All numbers are positive integer not larger than 2020.
Output
If the game can last forever, print Inf in a single line, otherwise please output the longest time in seconds each game can last, which should be printed accurately rounded to three decimals.
Sample Input
2
3 1
1 1 1
3 1
3 2 1
Sample Output
Inf
3.142
#include <cstdio>#include <cmath>double pi = acos(-1);const int eps = 1e-8;int main(){ int t; scanf("%d",&t); while (t--){ int n; int r; int a; int sum = 0; int tr = 0; int first; scanf("%d%d",&n,&r); for (int i = 0; i < n; ++i){ scanf("%d",&a); if (i == 0) first = a; if (tr > a) sum+=tr-a; tr = a; } if (tr > first) sum += tr-first; if (sum == 0) printf("Inf\n"); else printf("%.3lf\n",(double)2*pi*r/sum); } return 0;}
按顺序排列蚂蚁 但是是按圆排列的 所以 1 2 3 与 2 3 1 与3 1 2 是等价的 题意是求任意一个蚂蚁追上它之前的蚂蚁的最大时间 (安排距离来满足 ) 如果这一位蚂蚁比它之前的速度小或相等 那么它就不可能追得上 所以只有所有蚂蚁的速度都相等才能是inf 其他就算是找到相邻速度差最大的那个速度 即Δvmax*t=2*pi*r 求解t即可
- ants run 题意理解
- UESTC 1171 Ants Run!
- UESTC 95 Ants Run! 水题
- Lucky Division【理解题意】
- 【理解题意】HDU2060Snooker
- 地牢逃脱-理解题意
- nyoj 618 追击【理解题意】
- hdu_5099 理解题意要求即可
- ccccleve_1总结 注意理解题意
- poj2709 Painter(关键在于理解题意)
- 字符串- 题意理解与转换
- 题意!!!
- poj 2856 水题 题意难理解
- poj 2603 注意理解题意 数论
- UVA10300(理解题意就容易切)
- Song Jiang's rank list【理解题意】
- hdu 产生冠军(充分理解题意)
- cf554题意的理解和组合问题
- 102OpenStack基础原理
- Javascript刷新页面的几种方法:
- 作业4:基本查询语句
- codeforce 796 c Bank Hacking (思维题,分类讨论)
- CodeForces
- ants run 题意理解
- 移动零
- Follow me 挑战程序与设计
- hdu 1875 畅通工程再续(MST)
- hdu 4738 Caocao's Bridges 【求最小代价的割边(桥)】
- 读书笔记:Hyperbolic reductions for Einstein's equations(Helmut Friedrich 1996)
- CS231n系列课程Lecture 5:Train Neural Networks, Part 1
- js输出选中的多选框的个数
- 第三十五讲项目一 另类求和