Snooker(2060)
2015-09-07 19:26
381 查看
*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
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <list>
#include <map>
#include <string>
using namespace std;
#define infinity 2147483647
#define pi 3.1415926535898
#define g 9.81
int gcd(int a,int b)
{
return b==0?a:gcd(b,a%b);
}
int maxx(int a,int b)
{
return a>=b?a:b;
}
int main()
{
int n,num,p1,p2,sum;
cin >>n;
while(n--)
{
cin >>num >>p1 >>p2;
sum=p1;
if(num>6) //有红球
{
sum=p1+(num-6)*8+7+6+5+4+3+2;
}
else if(num==6) //无红球
{
sum=p1+7+6+5+4+3+2;
}
else if(num==5)
{
sum=p1+7+6+5+4+3;
}
else if(num==4)
{
sum=p1+7+6+5+4;
}
else if(num==3)
{
sum=p1+7+6+5;
}
else if(num==2)
{
sum=p1+7+6;
}
else if(num==1)
{
sum=p1+7;
}
if(sum>=p2) //注意等于号
cout <<"Yes" <<endl;
else
cout <<"No" <<endl;
}
return 0;
}
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
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <list>
#include <map>
#include <string>
using namespace std;
#define infinity 2147483647
#define pi 3.1415926535898
#define g 9.81
int gcd(int a,int b)
{
return b==0?a:gcd(b,a%b);
}
int maxx(int a,int b)
{
return a>=b?a:b;
}
int main()
{
int n,num,p1,p2,sum;
cin >>n;
while(n--)
{
cin >>num >>p1 >>p2;
sum=p1;
if(num>6) //有红球
{
sum=p1+(num-6)*8+7+6+5+4+3+2;
}
else if(num==6) //无红球
{
sum=p1+7+6+5+4+3+2;
}
else if(num==5)
{
sum=p1+7+6+5+4+3;
}
else if(num==4)
{
sum=p1+7+6+5+4;
}
else if(num==3)
{
sum=p1+7+6+5;
}
else if(num==2)
{
sum=p1+7+6;
}
else if(num==1)
{
sum=p1+7;
}
if(sum>=p2) //注意等于号
cout <<"Yes" <<endl;
else
cout <<"No" <<endl;
}
return 0;
}
相关文章推荐
- Linux C函数参考手册(PDF版)
- Lua教程(十七):C API简介
- C#实现打造气泡屏幕保护效果
- C/C++数据对齐详细解析
- 利用C语言来求最大连续子序列乘积的方法
- 字符串的组合算法问题的C语言实现攻略
- C 语言基础教程(我的C之旅开始了)[三]
- C++中的extern “C”用法详解
- C 语言基础教程(我的C之旅开始了)[七]
- 最大子矩阵问题实例解析
- C字符串操作函数实现方法小结
- 字典树的基本知识及使用C语言的相关实现
- 详解C语言中free()函数与getpagesize()函数的使用
- C/C++ 宏详细解析
- 使用C语言解决字符串全排列问题
- C/C++实现对STORM运行信息查看及控制的方法
- 用C#生成不重复的随机数的代码
- 在c和c++中实现函数回调
- 浅析C/C++中被人误解的SIZEOF