您的位置:首页 > 产品设计 > UI/UE

(博弈) HOJ 2939 Coin Question

2014-02-08 09:53 399 查看

Coin Question

My Tags  (Edit)
Source : ACM Group
Time limit : 1 secMemory limit : 64 M
Submitted : 360, Accepted : 194Every HCPC(HIT Collegiate Programming Contest), Participants will check if Robin has set a problem. The reason is so obvious -- he has been so weak, how hard can his problem be.This year, tradition goes on. You can solve this problem within one minute, or two minutes at most.Here is the problem. Robin has a round table with radius R (0.00 <= R <= 100000000.00), and a lot of same coins (you can assume they are infinite) with radius r (0.00 <= r <= 10000.00). Robin invites two friends, Mr. Wendy and Mr. Pian, to play a game. Rules are as follows.1. Mr. Wendy and Mr. Pian take turns to place one coin on the table. Mr. Wendy first.
2. One can place the coin anywhere on the table, but he can't place it on any other coins, even one corner is not allowed.
3. One can't let the coin which he places hang in the air, which means any part of the coin must be close to the table's surface.
4. The person who can't place a coin on the table loses the game.Input[/b]The input data are of various cases.Each case consists of two float numbers. Round table's radius R and the coin's radius r.The input ends with EOF.
Output[/b]For each case, If Mr. Wendy wins the game, you should output a line:
Yes, Mr. Wendy is a ****ing genius!
Or, you should output the line:
No, Mr. Pian is the real ****ing genius!
Sample Input[/b]4.00 4.00
4.00 5.00
Sample Output[/b]Yes, Mr. Wendy is a ****ing genius!
No, Mr. Pian is the real ****ing genius!


题意:有一张半径为R的桌子,然后有半径为r的硬币,然后两个人轮流在桌子上面放硬币,最后放不了硬币的人输。
思路:如果能想到还是很简单的,首先先放的人是能必定能赢得,如果一开始他能放的话,先放的人的策略是直接把一个硬币放在中心,然后对方放在哪里我们就放在他放的位置的中心对称的地方,那么最后一定是对方放不下。所以要自己输只有当硬币的大小比桌子大的时候才会输。
代码:#include<iostream>#include<cstdio>#include<cstring>#include<string.h>using namespace std;#define eps 1e-8int main(){ double R , r; while (cin>>R>>r) { if (R < r) printf("No, Mr. Pian is the real ****ing genius!\n"); else  printf("Yes, Mr. Wendy is a ****ing genius!\n"); }}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: