2011 Multi-University Training Contest 3 - Host by BIT
2011-08-30 10:59
423 查看
The Lost Traveler
[b]Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 556 Accepted Submission(s): 153
[/b]
Problem Description
Bob is a robot who lives in a two-dimensional world. One day, he decided to go out for a travel. There are two kinds of traveling ways for Bob: to walk forward, and to rotate. When he searched the path with his iPhone 4, he only downloaded part of the data
because of the bad signal. The data just indicated a series of directions for rotation. Bob decided to go on his trip according to this data.
Bob got started at the center of the two-dimensional world (at least he thought he did), and began to move forward. He can walk far enough (but he can't stay at the same place, even in starting point) and then stop to rotate according to the data. The paths
can get intersected.
However, Bob didn't know whether he could get back home or not. So he turned to you for help.
For example, the data indicates like this:
Move forward (He must move for a distance greater than zero. He must not stay and make the next turning without moving forward. The same goes for the following.)
Turn 120 degrees anti-clockwise
Move forward
Turn 120 degrees clockwise
Move forward
Turn 120 degrees clockwise
Move forward
Bob could walk like the figure shows, and he'll get back home.
Input
The first line of the input gives the number of test cases, T. T est cases follow.
Each test case begins with a line containing an integer N,representing the number of degrees. N degrees follow.0<N<100000
Each line contains a number D with a precision of two decimal places, positive for clockwise, negative for anti-clockwise. (-360.00 <= D <= 360.00)
Output
For each case, output one line. If bob can go back to start point, print "Yes". Otherwise, print "No".
Sample Input
2 3 -120.00 120.00 120.00 2 120.00 -120.00
Sample Output
Yes No
#include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> #include<algorithm> #define eps 1e-6 using namespace std; double a[100010]; int main() { int cas; int n,i; bool flag; scanf("%d",&cas); while(cas--) { a[0]=0; flag=true; scanf("%d",&n); for(i=1;i<=n;i++) { double b; scanf("%lf",&b); a[i]=360.0+a[i-1]+b; while(a[i]>=360.0) a[i]-=360.0; } sort(a+1,a+n+1); for(i=1;i<=n;i++) if(a[i]-a[i-1]>=180) { flag=false; break; } if(a <=180) flag=false; if(n==1&&a[1]==180) flag=true; if(flag) printf("Yes\n"); else printf("No\n"); } return 0; }
相关文章推荐
- Moonfang's Birthday&&2011 Multi-University Training Contest 3 - Host by BIT
- 【转】2011 Multi-University Training Contest 3 - Host by BIT
- HDU HDU 3861 The King’s Problem 2011 Multi-University Training Contest 3 - Host by BIT
- HDU 3917 Road constructions 2011 Multi-University Training Contest 8 - Host by HUST 最大权闭包
- HDU3836 Equivalent Sets 2011 Multi-University Training Contest 1 - Host by HNU
- HDU 3870 Catch the Theves 2011 Multi-University Training Contest 4 - Host by SDU
- HDU3879 Base Station 最大权闭合图/最大密度子图 2011 Multi-University Training Contest 5 - Host by BNU
- HDU3917 Road constructions 最大权闭合图 2011 Multi-University Training Contest 8 - Host by HUST
- 2011 Multi-University Training Contest 1 - Host by HNU&&R(N)
- HDU3912 Turn Right 模拟 2011 Multi-University Training Contest 8 - Host by HUST
- HDU 3974 Assign the task 2011 Multi-University Training Contest 14 - Host by FZU 线段树
- 2011 Multi-University Training Contest 1 - Host by HNU
- HDU 3972 1 M possible 2011 Multi-University Training Contest 14 - Host by FZU
- HDU 3830 Checkers 2011 Multi-University Training Contest 1 - Host by HNU
- hdu3832(2011 Multi-University Training Contest 1 - Host by HNU )
- 2011 Multi-University Training Contest 1 - Host by HNU&&Earth Hour
- HDU3996 Gold Mine最大权闭合图 2011 Multi-University Training Contest 16 - Host by TJU
- 【解题报告】2011 Multi-University Training Contest 1-Host by HNU
- HDU 3879 Base Station 最大权闭包 2011 Multi-University Training Contest 5 - Host by BNU
- HDU3998 Sequence 动态规划+最大流2011 Multi-University Training Contest 16 - Host by TJU