HDOJ2060_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
题目大意:一个台球游戏,如果玩家能赢(或者平手)就输出Yes,不嫩赢就输出No。
一共有15个红球(普通球),还有6个彩色球,进一个红球得一分,进一个彩色球得分分别是:yellow(2 point), green(3 point), brown(4 point),
blue(5 point), pink(6 point), black(7 point)。并且,每进一个红球可以得到一次打彩色球的机会,每进一个彩色球得到一次打红色球的机会(当然这是在有
红色球的情况下),在有红球剩余的情况下,进了的彩色球需要再放回。
现在输入一个整数,表示示例组数,然后第一个是剩余球数量(不是红球数),有红球的时候,6个彩色球都在,第二个是玩家得分,第三个是对手得分,需要判断玩家时候有
机会赢(或者平手)。
显然,如果进了一个红球,当然选择打黑球,因为他的分数最高
下面AC代码:
import java.util.Scanner;

public class Main {
	private static Scanner scanner;
	public static void main(String[] args) {
		scanner = new Scanner(System.in);
		while(scanner.hasNext()){
			int n = scanner.nextInt();
			while(n-->0){
				int Ball_Left = scanner.nextInt();
				int P_Score = scanner.nextInt();
				int  O_Score = scanner.nextInt();
				int[] a = {7,6,5,4,3,2};
				
				int sum = 0;
				if(Ball_Left>6){
					sum = (Ball_Left-6)+(Ball_Left-6)*7+27;
				}else {
					for (int i = 0; i < Ball_Left; i++) {
						sum += a[i]; 
					}
				}
				if(P_Score+sum >= O_Score){
					System.out.println("Yes");
				}else {
					System.out.println("No");
				}
			}
		}
	}
}




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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值