▲1.7 [hduoj] 2060 Snooker

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

2

12 1 1

1 30 39

Sample Output

Yes

No

#include<stdio.h>
void main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        while(n--)
        {
            int m,iscore,oscore;
            scanf("%d%d%d",&m,&iscore,&oscore);
            int hscore=0;
            if(m>6)
                hscore=(m-6)*1+(m-6)*7+27;
            else
                hscore=(15-m)*m/2;
            if(iscore+hscore>=oscore)
                printf("Yes\n");
            else
                printf("No\n");
        }
    }
}

这题。。我连意思都理解半天。不想直接网上翻译,就自己慢慢翻了。

背景:菲利普喜欢玩qq游戏的斯诺克当他想要放松的时候,尽管他仅仅是个小菜鸟。可能你以前没有玩过这个游戏,不要紧,首先我将会给你介绍规则。有21个球在台球桌上,包含15个红球和6个各种颜色的球:黄色,绿色,棕色,蓝色,粉色,黑色。玩家应该使用一个白球来使其他球滚入洞里。被他打入洞离的球的固定的分数的总和,就是这个玩家的总分。这个玩家首先应该将红球打入洞里,在他获得了红球的分数(1分)以后,然后他就有机会打有颜色的球了,然后轮流。有颜色的球应该被打入洞中,直到所有红球都进洞。换句话说,如果只有有颜色的球在台球桌上,玩家应该按照这样的顺序把球打入洞里:黄色(2分),绿色(3分),棕色(4分),蓝色(5分),粉色(6分),黑色(7分),在所有球都被打进洞以后,她们不会从洞里出来,在没有球留在台球板上以后,这个游戏结束了。这个游戏结束以后,拥有更高分数的玩家,赢得了这场游戏。ps:红球从来不会从洞里出来。我仅仅阐述了可能使用到的规则,如果你想要联系更多细节的话请戳:http://sports.tom.com/snooker/在这个竞赛以后。

举个例子,如果有12个红球在台球桌上(如果有一个静止的红球留在台球桌上,可以确信所有有颜色的球也必须在台球桌上)。所以假如菲利普能够继续把球撞到洞里,它可以获得最大的分数是12*1(12个球在射击以后)+7*12(在撞击一个红球后,一个分数最高的黑球应该成为目标)+2+3+4+5+6+7(当没有红球剩下的时候,使得所有有颜色的球都进洞。)

现在你的任务是去判断菲利普是否应该做决定去放弃当告诉他台球桌上的情况以后(有多少个球任然留在桌子上没有进洞,和其他玩家的分数。)如果菲利普仍然有机会胜利,就输出yes,如果没有就输出no。(ps:如果他能够得到的最大的分数和他现有的分数等于对手的分数,仍然输出yes)

输入 第一行包含一个数字N表明总共可能的情况数,然后跟着N行,每一行都由三个整数组成:剩下的球数,本玩家的分数以及对手玩家的分数,所有的输入的值都在32位整数的范围内。

输出 你应该就算最大的菲利普还能得到的分数,然后判断它是否可能胜利。

这你敢信,我也就是这个游戏规则理解了一下午边刷微博边东摸摸西摸摸,我服了我自己。后来发现其实根本不需要对规则理解透。只要知道这题怎么解好了。

就是如果还剩的球数小于六的话,就视为全部都是颜色球,并且根据规则只能是分数大的那几个球。

如果剩的球数比6大的话,就视为6个颜色球加上红球。因为每个颜色球进洞以后,每个球都可以增加黑球的分数。所以还要加上增加的分数。

发布了153 篇原创文章 · 获赞 4 · 访问量 3712

猜你喜欢

转载自blog.csdn.net/qq_39782006/article/details/103875469
1.7