HDU2060Snooker
2016-01-12 14:44
274 查看
Snooker
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 8981 Accepted Submission(s): 3819
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
其实我也比较喜欢打桌球的,不过斯诺克规则倒是真的不怎么了解;
不了解的朋友可以百度下就可以知道了,题目中也有给出;
就是一共有21个球, 15个红球,6个彩球,分别有: 黄球,绿球,棕球,蓝球,粉球,黑球;
每击进一个红球得 1 分 ,彩球按按其顺序来分别是 2分 3分 4分 5分 6分 7分;
斯诺克一杆击球的最高得分是 147分: 147=(1+7)*15+2+3+4+5+6+7;
斯诺克比赛的击球规则是,第一球只能击红球,击红球后,再击彩球,再红球全部击完之前,每次击落的彩球都是要重新回到球桌的;
这题很显然是要我们求 Philp 面对剩下的球时,能得到的最大的分数,那么必须是一杆清,而且是打出分数最大化,也就是只要场上还存在红球,就是 红球->黑球->红球->黑球......的击落顺序;
给出AC代码:
#include<iostream> using namespace std; int main() { int n, ps, os, ln; cin >> n; int max; while (n--) { max = 0; cin >> ln >> ps >> os; if (ln > 6)max = (7 + 1) * (ln-6) + 2 + 3 + 4 + 5 + 6 + 7; if (ln <= 6) { int k = 7; for (int i = 1; i <= ln; i++,k--) { max += k; } } max += ps; if (max >= os)cout << "Yes" << endl; else cout << "No" << endl; } return 0; }
相关文章推荐
- 安卓动画详解——帧动画
- iOS应用性能调优的25个建议和技巧
- JAVA Builder模式构建MAP/LIST的示例
- maven 错误列表
- 一个div 实现六个矩形
- [Andorid开发艺术探索 读书笔记]View的事件体系(二)
- 野生Js技术之字符画视频
- Swift入门 01常量&变量
- 持续集成
- Azure云服务反向DNS
- iOS 开发 版本控制 svn + Versions/Cornerstone
- C#窗体应用程序 vs + sql server2008连接举例,简单的学生信息管理系统
- oracle temporary tables
- 解决更新Android SDK时出现A folder failed to be renamed or moved办法
- MySql 里的IFNULL、NULLIF和ISNULL用法
- 在IJ上调式远程jetty和tomcat
- logger(一):C++ & logger模块配置及开发
- [easyui]封装一个datagrid
- 资源管理概念的形象化
- STM8 选项字节的写入