HDOJ(HDU) 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

题目意思我开始没看懂,参考了其他大牛的题意分析。

题意:

桌上有n个球,一人得分为a,另一人为b,问如果第一个人将n个球都打进洞后,得分能否超过(或等于)第二个人。
总共有15个红球,和6个有颜色的球,每个红球的得分为1 ,6
个有颜色的球分别为2 , 3, 4 ,5, 6, 7 ;

分析:

1。如果n>6 ,
那么桌上有6个彩球和n-6个红球,但是由于有色球全部打进洞后,每个球需要额外增加黑球(最高得分)的得分;所以打进n个球的得分为:
(n-6)*1+(n-6)*7+2+3+4+5+6+7

2.当 m <= 6 时,
应该由价值最高的黑球( 7 分) 向前依
次增加求和,又因为有色球满足等差数列 ,由前6项减去前 6 - m项和,所以
求得为( 7 - m + 1 + 7 ) * m / 2 ( 这里直接通过得分来计算的)。因
此,第二种情况的得分为( 15 - m ) *m/ 2 ;

import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        int[] db = {0,7,13,18,22,25,27};
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            int n =sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();

            if(n<=6){
                if(b+db[n]>=c){
                    System.out.println("Yes");
                }else{
                    System.out.println("No");
                }
            }else{
                if(b+(1*(n-6)+7*(n-6)+db[6])>=c){
                    System.out.println("Yes");
                }else{
                    System.out.println("No");
                }
            }
        }
    }
}
时间: 2024-09-29 12:23:12

HDOJ(HDU) 2060 Snooker(英语很重要。。。)的相关文章

HDOJ/HDU 1804 Deli Deli(英语单词复数形式~)

Problem Description Mrs. Deli is running the delicatessen store "Deli Deli". Last year Mrs. Deli has decided to expand her business and build up an online store. She has hired a programmer who has implemented the online store. Recently some of h

HDOJ(HDU) 2500 做一个正气的杭电人(水~)

Problem Description 做人要有一身正气,杭电学子都应该如此.比如我们今天的考试就应该做到"诚信"为上. 每次考试的第一个题目总是很简单,今天也不例外,本题是要求输出指定大小的"HDU"字符串,特别地,为了体现"正气"二字,我们要求输出的字符串也是正方形的(行数和列数相等). Input 输入的第一行包含一个正整数N(N<=20),表示一共有N组数据,接着是N行数据,每行包含一个正整数M(M<=50),表示一行内有M个

HDOJ(HDU) 1465 不容易系列之一(错排)

Problem Description 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了! 做好"一件"事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的道理一样. 话虽这样说,我还是要告诉大家,要想失败到一定程度也是不容易的.比如,我高中的时候,就有一个神奇的女生,在英语考试的时候,竟然把40个单项选择题全部做错了!大家都学过概率论,应该知道出现这种情况的概率,所以至今我都觉得这是一件神奇的事情.如果套用一句经典的评语,我们可以这样总结

HDOJ(HDU) 2153 仙人球的残影(谜一样的题、、、)

Problem Description 在美丽的HDU,有一名大三的同学,他的速度是众所周知的,跑100米仅仅用了2秒47,在他跑步过程中会留下残影的哎,大家很想知道他是谁了吧,他叫仙人球,既然名字这样了,于是他的思想是单一的,他总是喜欢从一点出发,经过3次转折(每次向右转90°),回到出发点,而且呢,他每次转折前总是跑相同长度的路程,所以很多人都想知道如果用'1'算他跑步出发的第一个残影的话,那么回到起点的时候,他的残影是怎么样的呢?   Input 测试数据有多行,每一行为一个数N(1<=N

HDOJ(HDU) 2186 悼念512汶川大地震遇难同胞——一定要记住我爱你

Problem Description 当抢救人员发现她的时候,她已经死了,是被垮塌下来的房子压死的,透过那一堆废墟的的间隙可以看到她死亡的姿势,双膝跪着,整个上身向前匍匐着,双手扶着地支撑着身体,有些象古人行跪拜礼,只是身体被压的变形了.救援人员从废墟的空隙伸手进去确认了她已经死亡,又在冲着废墟喊了几声,用撬棍在在砖头上敲了几下,里面没有任何回应. 当人群走到下一个建筑物的时候,救援队长忽然往回跑,边跑变喊"快过来".他又来到她的尸体前,费力的把手伸进女人的身子底下摸索,他摸了几下高

HDOJ/HDU 1161 Eddy&amp;#39;s mistakes(大写字母转换成小写字母)

Problem Description Eddy usually writes articles ,but he likes mixing the English letter uses, for example "computer science" is written frequently "coMpUtEr scIeNce" by him, this mistakes lets Eddy's English teacher be extremely disco

HDOJ/HDU 1865 1sting(斐波拉契+大数~)

Problem Description You will be given a string which only contains '1'; You can merge two adjacent '1' to be '2', or leave the '1' there. Surly, you may get many different results. For example, given 1111 , you can get 1111, 121, 112,211,22. Now, you

HDOJ/HDU 1087 Super Jumping! Jumping! Jumping!(经典DP~)

Problem Description Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now. The game can be played by two or more t

HDOJ/HDU 1088 Write a simple HTML Browser(HTML字符串)

Problem Description If you ever tried to read a html document on a Macintosh, you know how hard it is if no Netscape is installed. Now, who can forget to install a HTML browser? This is very easy because most of the times you don't need one on a MAC