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

题目意思我开始没看懂,参考了其他大牛的题意分析。

题意:

桌上有n个球,一人得分为a,另一人为b,问如果第一个人将n个球都打进洞后,得分能否超过(或等于)第二个人。

总共有15个红球,和6个有颜色的球,每个红球的得分为1 ,6

个有颜色的球分别为2 , 3, 4 ,5, 6, 7 ;

分析:

1。如果n>6 ,

那么桌上有6个彩球和n-6个红球,但是由于有色球全部打进洞后,每个球需要额外增加黑球(最高得分)的得分;所以打进n个球的得分为:

(n-6)*1+(n-6)*7+2+3+4+5+6+7

2.当 m <= 6 时,

应该由价值最高的黑球( 7 分) 向前依

次增加求和,又因为有色球满足等差数列 ,由前6项减去前 6 - m项和,所以

求得为( 7 - m + 1 + 7 ) * m / 2 ( 这里直接通过得分来计算的)。因

此,第二种情况的得分为( 15 - m ) *m/ 2 ;

import java.util.Scanner;

public class Main{
public static void main(String[] args) {
int[] db = {0,7,13,18,22,25,27};
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int n =sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt(); if(n<=6){
if(b+db[n]>=c){
System.out.println("Yes");
}else{
System.out.println("No");
}
}else{
if(b+(1*(n-6)+7*(n-6)+db[6])>=c){
System.out.println("Yes");
}else{
System.out.println("No");
}
}
}
}
}

HDOJ(HDU) 2060 Snooker(英语很重要。。。)的更多相关文章

  1. HDOJ(HDU).2044-2049 递推专题

    HDOJ(HDU).2044-2049 递推专题 点我挑战题目 HDU.2044 题意分析 先考虑递推关系:从1到第n个格子的时候由多少种走法? 如图,当n为下方格子的时候,由于只能向右走,所以有2中 ...

  2. HDOJ(HDU).1258 Sum It Up (DFS)

    HDOJ(HDU).1258 Sum It Up (DFS) [从零开始DFS(6)] 点我挑战题目 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双 ...

  3. HDOJ(HDU).1015 Safecracker (DFS)

    HDOJ(HDU).1015 Safecracker [从零开始DFS(2)] 从零开始DFS HDOJ.1342 Lotto [从零开始DFS(0)] - DFS思想与框架/双重DFS HDOJ.1 ...

  4. HDOJ(HDU).1412 {A} + {B} (STL SET)

    HDOJ(HDU).1412 {A} + {B} (STL SET) 点我挑战题目 题意分析 大水题,会了set直接用set即可. 利用的是set的互异性(同一元素有且仅有一项). #include ...

  5. HDOJ(HDU).1754 I Hate It (ST 单点替换 区间最大值)

    HDOJ(HDU).1754 I Hate It (ST 单点替换 区间最大值) 点我挑战题目 题意分析 从题目中可以看出是大数据的输入,和大量询问.基本操作有: 1.Q(i,j)代表求区间max(a ...

  6. HDOJ(HDU).1166 敌兵布阵 (ST 单点更新 区间求和)

    HDOJ(HDU).1166 敌兵布阵 (ST 单点更新 区间求和) 点我挑战题目 题意分析 根据数据范围和询问次数的规模,应该不难看出是个数据结构题目,题目比较裸.题中包括以下命令: 1.Add(i ...

  7. HDOJ(HDU).2844 Coins (DP 多重背包+二进制优化)

    HDOJ(HDU).2844 Coins (DP 多重背包+二进制优化) 题意分析 先把每种硬币按照二进制拆分好,然后做01背包即可.需要注意的是本题只需要求解可以凑出几种金钱的价格,而不需要输出种数 ...

  8. HDOJ(HDU).1059 Dividing(DP 多重背包+二进制优化)

    HDOJ(HDU).1059 Dividing(DP 多重背包+二进制优化) 题意分析 给出一系列的石头的数量,然后问石头能否被平分成为价值相等的2份.首先可以确定的是如果石头的价值总和为奇数的话,那 ...

  9. HDOJ(HDU).2191. 悼念512汶川大地震遇难同胞――珍惜现在,感恩生活 (DP 多重背包+二进制优化)

    HDOJ(HDU).2191. 悼念512汶川大地震遇难同胞――珍惜现在,感恩生活 (DP 多重背包+二进制优化) 题意分析 首先C表示测试数据的组数,然后给出经费的金额和大米的种类.接着是每袋大米的 ...

随机推荐

  1. 几种任务调度的 Java 实现方法与比较--转载

    前言 任务调度是指基于给定时间点,给定时间间隔或者给定执行次数自动执行任务.本文由浅入深介绍四种任务调度的 Java 实现: Timer ScheduledExecutor 开源工具包 Quartz ...

  2. text-overflow:ellipsis的巧妙运用

    关键字: text-overflow:ellipsis 语法:text-overflow : clip | ellipsis 取值: clip :默认值 .不显示省略标记(...),而是简单的裁切. ...

  3. 【转】HttpServlet详解

    [转]HttpServlet详解 Servlet的框架是由两个Java包组成:javax.servlet和javax.servlet.http. 在javax.servlet包中定义了所有的Servl ...

  4. ASP.NET MVC 几种 Filter 的执行过程源码解析

    一.前言 之前也阅读过MVC的源码,并了解过各个模块的运行原理和执行过程,但都没有形成文章(所以也忘得特别快),总感觉分析源码是大神的工作,而且很多 人觉得平时根本不需要知道这些,会用就行了.其实阅读 ...

  5. Scene is unreachable due to lack of entry points and does not have an identifier for runtime access

    使用Storyboard时出现以下警告: warning: Unsupported Configuration: Scene is unreachable due to lack of entry p ...

  6. Java安全发布的理解

    看<Java并发编程实战>遇到如下问题 代码: /** * Created by yesiming on 16/11/11. */public class Holder { private ...

  7. linux变量心得

    前一段时间学习了一下linux的变量,现在总结有3点需要特别注意: linux变量和C/C++变量的区别 linux变量的引用 linux变量特有的命令替换 先说第一点,linux变量更像是宏定义,只 ...

  8. Java学习----对象的状态和行为

    1.什么是对象 对象是已知的事物 对象会执行动作 类是对象的蓝图 2.对象的属性和状态 使用变量来描述 private String name; private int age; private St ...

  9. Android学习----Android Studio 技巧汇总

    关于快捷键 The File Structure Popup ctrl+f12此快捷键可以调出当前文件的大纲,并通过模糊匹配快速跳转至指定的方法.勾选上“show anonymous classes” ...

  10. JQUERY1.9学习笔记 之内容过滤器(二) 空元素选择器

    描述:选择没有子元素(包括文本节点)的标签. jQuery(":empty") 与:parent相反. 例:找出所有为空的元素.(他们没有子元素或文本元素). <!docty ...