hdu 2060 Snooker

来源:互联网 发布:阿里云虚拟机怎么登陆 编辑:程序博客网 时间:2024/05/14 00:59

Snooker

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6651    Accepted Submission(s): 2819


Problem Description
background:
Philip likes to play the QQ game of Snooker when he wants a relax, though he was just a little vegetable-bird. Maybe you hadn't played that game yet, no matter, I'll introduce the rule for you first.
There are 21 object balls on board, including 15 red balls and 6 color balls: yellow, green, brown, blue, pink, black.
The player should use a white main ball to make the object balls roll into the hole, the sum of the ball's fixed value he made in the hole is the player's score. The player should firstly made a red ball into the hole, after that he gains red-ball's value(1 points), then he gets the chance to make a color ball, then alternately. The color ball should be took out until all the red-ball are in the hole. In other word, if there are only color balls left on board, the player should hit the object balls in this order: yellow(2 point), green(3 point), brown(4 point), blue(5 point), pink(6 point), black(7 point), after the ball being hit into the hole, they are not get out of the hole, after no ball left on board, the game ends, the player who has
the higher score wins the game. PS: red object balls never get out of the hole.
I just illustrate the rules that maybe used, if you want to contact more details, visit http://sports.tom.com/snooker/ after
the contest.

for example, if there are 12 red balls on board(if there are still red ball left on board, it can be sure that all the color
balls must be on board either). So suppose Philp can continuesly hit the ball into the hole, he can get the maximun score is
12 * 1 (12 red-ball in one shoot) + 7 * 12(after hit a red ball, a black ball which was the most valuable ball should be the target) + 2 + 3 + 4 + 5 + 6 + 7(when no red ball left, make all the color ball in hole).
Now, your task is to judge whether Philip should make the decision to give up when telling you the condition on board(How many object balls still left not in the hole and the other player's score). If Philp still gets the chance to win, just print "Yes", otherwise print "No". (PS: if the max score he could get on board add his current score is equal to the opponent's current score, still output "Yes")
 

Input
The first line contains a numble N indicating the total conditions. Then followed by N lines, each line is made of three integers:
Ball_Left P_Score O_Score represeting the ball number left on board, Philp's current score, and the opponent's current score.
All the input value are in 32 bit integer value range.
 

Output
You should caculate the max score left Philp can gain, and judge whether he has the possiblity to win.
 

Sample Input
212 1 11 30 39
 

Sample Output
YesNo
 

斯诺克的桌球游戏,关键在于对题目的理解

下面是别的大牛解释的题意

 

题意为,给你场上剩下的球数m , 和 a ,b 两名队员目前得分,现在假设a将

所有的球m都打入洞中,然后让你输出是否最终a的得分会超过b;

              总共有15个红球,和6个有颜色的球,每个红球的得分为1 ,6

个有颜色的球分别为2 , 3, 4 ,5, 6, 7 ;

              因为 要求最大得分,需要考虑的情况有两种;

              A :当 m > 6时 ,应该将有颜色的球都取了,有色球得分为

2 + 3  + 4 + 5 + 6 + 7 ,有色球总得分为27 ;然后再取红球 m  -  6 ,本

来得分应该是 ( m - 6 ) * 1 ,但是由于有色球全部打进洞后,每个球需要

额外增加黑球(最高得分)的得分;所以红球总得分为( m - 6 ) * 1 + ( m

- 6 ) * 7 ;

                总得分为( m - 6 ) * 8 + 27 ;

              B:当 m <= 6 时 ,应该由价值最高的黑球( 7 分) 向前依

次增加求和,又因为有色球满足等差数列 ,由前6项减去前 6 - m项和,所以

求得为( 7 - m  + 1 + 7  ) * m / 2 ( 这里直接通过得分来计算的)。因

此,第二种情况的得分为( 15 - m ) *m/ 2 ;

 

#include<iostream>#include <stdio.h>using namespace std;int main(){    int n;    cin>>n;    int m,a,b;    while (n--)    {        cin>>m>>a>>b;        if(m>6)        {            a=a+(m-6)*8+27;        }        else        {            a=a+(15-m)*m/2;        }        if(a>=b)        {            cout<<"Yes"<<endl;        }        else        {            cout<<"No"<<endl;        }    }    return 0;}


0 0
原创粉丝点击