首页 > 代码库 > HDU2060 Snooker【水题】
HDU2060 Snooker【水题】
Snooker
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 7261 Accepted Submission(s): 3108
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
Author
zl
题目大意:斯诺克规则是总共有15个红球和6个彩球,打球顺序为打一个红球,进球得1分,
再打一个彩球,进球得彩球颜色相应分值(黄2 绿3 棕4 蓝5 粉6 黑7)。给你桌上还剩的球数、
A当前的比分,对手B当前的比分。假如A能将桌上还剩的球数都打进,问他是否能获胜。
思路:分有无红球,可分为6个球以上(有红球)的情况和6个球以下(无红球)的情况。分情况
计算就可以了。
#include<iostream> #include<algorithm> #include<cstdio> #include<cstring> using namespace std; int main() { int N; cin >> N; while(N--) { int ball,score1,score2; cin >> ball >> score1 >> score2; if(ball > 6) { score1 += (ball-6)*8+27; } else { int i = 7; while(ball--) { score1 += i; i--; } } if(score1 >= score2) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }
HDU2060 Snooker【水题】
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。