Hang electric brush oj title (2060)

Snooker (Snooker)

Subject description:

 

When Philip himself to relax, he likes to play QQ, snooker game, although he was just a little rookie. Maybe you do not know the rules of the game, it does not matter, I will introduce to you. A total of 21 balls on the table, including 15 red balls and 6 balls: yellow, green, brown, blue, pink, black. Players need to use a white ball to make the ball roll into the hole, the value of those balls and is represented by his score. Players must put a red ball into the hole, then it gets the corresponding scores red ball (1 point), then he will have a chance to choose to play a ball. Before all the red balls into the hole yet, hit the ball into the need to come up with. In other words, it is the last to leave the table will only colored balls. Player to hit the ball in the following order: yellow (2 points), green (3 points), brown (4 points), and blue (5 min), pink (6 points), and black (7 points). This time the ball into the hole, they will not be out. When there is no ball left on the table, the end of the game. High score player wins. PS: red ball will not come up again. I only just elaborate a little rule, if you want to know more information, please visit: http: //sports.tom.com/snooker/

 

For example, the table on stage as well as 12 red balls (if there are red balls left on the table, indicating that all the balls must also remain on the table). I assume that Philip could continue playing, he can get a maximum score is: 12 * 1 (one-off wiped out 12 red balls) + 7 * 12 (per kick a red ball hitting the ball) + 2 + 3 + 4 + 5 + 6 + 7 (when there is no remaining red ball, hit the ball all). Now, your task is in the case of Philip tell you now of the table (the number of balls left in the table) if he needs to give up the game after a judgment. If he still has a chance of winning, outputs "Yes", otherwise a "No". (PS: If he is the maximum possible score and now the score is equal to the opponent's score is 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

By the answer:

#include<stdio.h>
int main()
{
    int n,l,ps,os;
    int a[6]={7,6,5,4,3,2};
    while(scanf("%d",&n)!=EOF)
    {
    	while(n--){
    		scanf("%d%d%d",&l,&ps,&os);
    		if(l>6){                      //若球的个数大于6,则先打打完红球+黑球 (共8分) ,再打完彩球(共27分) 
			    ps+=8*(l-6)+27;
		    }else{                        //若球的个数小于6,则从分数大的开始打 
			    for(int i=0;i<l;i++){
				    ps+=a[i];
			    }
	        }
	     	if(ps>=os){                  //若总分大于等于对手,则可能赢 
			    printf("Yes\n");
		    }else{
			    printf("No\n");
	    	}
		}
		
        
    }
    return 0;
}

 

Published 76 original articles · won praise 3 · Views 1866

Guess you like

Origin blog.csdn.net/ZhangShaoYan111/article/details/104314531