A - Snooker

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
2
12 1 1
1 30 39
Sample Output
Yes

No

题解:先贴出百度后的垃圾机翻:

背景: 菲利普想放松一下,喜欢玩QQ游戏,虽然他只是一只小小鸟。也许你还没玩过那个游戏,不管怎样,我先给你介绍一下规则。 船上有21个目标球,包括15个红球和6个彩球:黄、绿、棕、蓝、粉、黑。 球员应使用一个白色的主球,使物体球滚入洞,球的固定值,他在洞里的总和是球员的得分。球员首先要把红球打进洞里,然后他得到红球的价值(1分),然后他有机会做一个彩球,然后交替。彩色球应该取出,直到所有红球都在洞里。换句话说,如果在船上只剩下彩球,球员应该按这个顺序击中目标球:黄色(2分),绿色(3分),棕色(4分),蓝色(5分),粉红色(6分),黑色(7分),球打到洞里后,他们不会离开洞,在没有留下球后,比赛结束,球员有。 更高的得分赢得比赛。红色物体球永远不能从洞里钻出来。 我只是说明可能采用的规则,如果你想接触更多的细节,http://sports.tom.com/snooker/后访问 比赛。 例如,如果有12个红色的球在船上(如果仍然有红色的球留在船上,它可以肯定所有的颜色。 球必须在船上的)。所以,假如Philp能连续击球入洞,他能得到的最大分数 12 * 1(12个红球在一个射击)+ 7 * 12(击中红球后,一个黑色的球,这是最有价值的球应该是目标)+ 2 + 3 + 4 + 5 + 6 + 7(当没有红球离开,使所有的彩色球在洞)。 现在,你的任务是判断菲利普是否应该做出放弃的决定,告诉你船上的情况(还有多少个目标球还没有留在洞里和其他球员的得分)。如果Philp仍然有机会赢,只是打印“是”,否则打印“不”。(PS:如果他能在船上获得的最大得分加上他当前的得分等于对手当前的得分,仍然输出“是”)。 输入 第一行包含一个数N表示总条件。接着是n行,每行由三个整数组成: ball_left p_score o_score象征球数左上,菲利普的得分,和对手的得分。 所有输入值都在32位整数值范围内。 输出 你应该得到的最大分数离开菲律宾能增益,并判断他是否有可能赢。

概括下大概意思是:斯洛克的规则为:一共15个红球,每个一分,6个彩球,黄色(2分),绿色(3分),棕色(4分),蓝色(5分),粉红色(6分),黑色(7分)选手先先用击打红球,红球进袋后得一分,并获得下一次击打彩球的机会,进袋得相应的分,然后红球,彩球交替击打,注意的是,在红球没能完全进入袋子中时,进袋得彩球会被拿出来有机会重新击打,知道所有的红球进袋再按从小到大的顺序把彩球击进袋。

所以,分成以下情况:

1.红球未全部击进袋中,即n>6,此时红球,彩球依次击打,且红球进袋后的目标为黑球时,得分最高,红球全部进袋后依次吧彩球打进袋中。

2.红球已经全部进袋,即n<=6,此时只有部分彩球,且击打的顺序是由小到大。

代码如下:

#include<stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int i,n,a,b;
	scanf("%d",&i);
	while(i--)
	{
		scanf("%d%d%d",&n,&a,&b);
		if( n > 6)
			a = a + (n - 6) * (7 + 1) + 27;
		else a = a + ((8 - n) + 7) * n/2;   //8-n是计算最小的彩球值,等差数列求和 
		if( a >= b)printf("Yes\n");
			else printf("No\n");
		
	}
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值