2015 Baidu STAR Program Design Competition, 2015 STAR Program Design
[Question link ]:Click here ~~
Du Xiong likes pranks. Today, he proposed a vulgar game to the visitors. He and the visitors take turns placing plates in a polygon. At last, the winner is the winner, who wins a kiss from the loser. After playing the game twice, he found that visitors knew the winning strategy of the game. Now he is always a pioneer and wants to know if he can win.
Note that the plates cannot interwork with the polygon or be placed outside the polygon. That is to say, the points in the plate cannot be outside the polygon or other plates.
[Solution] The Hint is the key to a mathematical problem, because he first places a plate in the middle of the polygon, and then whatever the visitor puts it, the little dual bears are symmetric Based on the center of the polygon and the visitor's plate to win ., Therefore, you only need to judge the diagonal length of the polygon and the plate radius (or diameter ).
Code:
# Include <stdio. h> # include <math. h> # include <string. h >#include <iostream >#include <algorithm> using namespace std; const int N = 1e5 + 5; int num [N]; const double eps = 1e-6; const double pi = acos (-1.0); int main () {int t, tot = 1; cin> t; while (t --) {double n, m, r; cin> n> m> r; printf ("Case # % d: \ n", tot ++); double ll = (m/2) /tan (pi/n); // polygon diagonal line length if (ll> r + eps) puts ("Give me a kiss! "); Else puts (" I want to kiss you! ");} Return 0 ;}