首页 > 代码库 > [ACM] HDU 5078 Osu!
[ACM] HDU 5078 Osu!
Osu!
Problem Description
Osu! is a very popular music game. Basically, it is a game about clicking. Some points will appear on the screen at some time, and you have to click them at a correct time.
Now, you want to write an algorithm to estimate how diffecult a game is.
To simplify the things, in a game consisting of N points, point i will occur at time ti at place (xi, yi), and you should click it exactly at ti at (xi, yi). That means you should move your cursor from point i to point i+1. This movement is called a jump, and the difficulty of a jump is just the distance between point i and point i+1 divided by the time between ti and ti+1. And the difficulty of a game is simply the difficulty of the most difficult jump in the game.
Now, given a description of a game, please calculate its difficulty.
Now, you want to write an algorithm to estimate how diffecult a game is.
To simplify the things, in a game consisting of N points, point i will occur at time ti at place (xi, yi), and you should click it exactly at ti at (xi, yi). That means you should move your cursor from point i to point i+1. This movement is called a jump, and the difficulty of a jump is just the distance between point i and point i+1 divided by the time between ti and ti+1. And the difficulty of a game is simply the difficulty of the most difficult jump in the game.
Now, given a description of a game, please calculate its difficulty.
Input
The first line contains an integer T (T ≤ 10), denoting the number of the test cases.
For each test case, the first line contains an integer N (2 ≤ N ≤ 1000) denoting the number of the points in the game. Then N lines follow, the i-th line consisting of 3 space-separated integers, ti(0 ≤ ti < ti+1 ≤ 106), xi, and yi (0 ≤ xi, yi ≤ 106) as mentioned above.
For each test case, the first line contains an integer N (2 ≤ N ≤ 1000) denoting the number of the points in the game. Then N lines follow, the i-th line consisting of 3 space-separated integers, ti(0 ≤ ti < ti+1 ≤ 106), xi, and yi (0 ≤ xi, yi ≤ 106) as mentioned above.
Output
For each test case, output the answer in one line.
Your answer will be considered correct if and only if its absolute or relative error is less than 1e-9.
Your answer will be considered correct if and only if its absolute or relative error is less than 1e-9.
Sample Input
2 5 2 1 9 3 7 2 5 9 0 6 6 3 7 6 0 10 11 35 67 23 2 29 29 58 22 30 67 69 36 56 93 62 42 11 67 73 29 68 19 21 72 37 84 82 24 98
Sample Output
9.2195444573 54.5893762558HintIn memory of the best osu! player ever Cookiezi.
Source
2014 Asia AnShan Regional Contest
水题,看懂题意,写代码就没问题。
代码:
#include <iostream> #include <stdio.h> #include <algorithm> #include <string.h> #include <cmath> #include <iomanip> #include <vector> #include <map> #include <stack> #include <queue> using namespace std; int n; struct Point { int x,y,t; }point[1002]; double dis(Point a,Point b) { return sqrt((double)(a.x-b.x)*(a.x-b.x)+(double)(a.y-b.y)*(a.y-b.y)); } int main() { int t;cin>>t; while(t--) { cin>>n; cin>>point[1].t>>point[1].x>>point[1].y; double ans=-1; for(int i=2;i<=n;i++) { cin>>point[i].t>>point[i].x>>point[i].y; double temp=dis(point[i],point[i-1])/(point[i].t-point[i-1].t); if(ans<temp) ans=temp; } cout<<setiosflags(ios::fixed)<<setprecision(9)<<ans<<endl; } return 0; }
[ACM] HDU 5078 Osu!
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。