Rich Game

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 72    Accepted Submission(s):
34

Problem Description
One day, God Sheep would like to play badminton but he
can’t find an opponent. So he request Mr. Panda to play with him. He said: “Each
time I win one point, I’ll pay you X

dollars. For each time I lose one point, you should give me Y

dollars back.”
God Sheep is going to play K

sets of badminton games. For each set, anyone who wins at least 11 points and
leads by at least 2 points will win this set. In other words, normally anyone
who wins 11 points first will win the set. In case of deuce (E.g. 10 points to
10 points), it’s necessary to lead by 2 points to win the set.
Mr. Panda is
really good at badminton so he could make each point win or lose at his will.
But he has no money at the beginning. He need to earn money by losing points and
using the money to win points.
Mr. Panda cannot owe God Sheep money as god
never borrowed money. What’s the maximal number of sets can Mr. Panda win if he
plays cleverly?

 
Input
The first line of the input gives the number of test
cases, T

. T

test cases follow.
Each test case contains 3 numbers in one line, X

, Y

, K

, the number of dollars earned by losing a point, the number of dollars paid by
winning a point, the number of sets God Sheep is going to play.
1≤T≤105.

1≤X,Y,K≤1000.

 
Output
For each test case, output one line containing “Case
#x: y”, where x

is the test case number (starting from 1) and y

is the maximal number of sets Mr. Panda could win.

 
Sample Input
2
10 10 1
10 10 2
 
Sample Output
Case #1: 0
Case #2: 1

Hint

In the first test case, Mr. Panda don’t have enough money to win the only set, so he must lose the only set.
In the second test case, Mr. Panda can lose the first set by 0:11 and he can earn 110 dollars. Then winning the second set by 11:0 and spend 110 dollars.

 
 
题意:两人玩游戏,输赢规则和乒乓球类似,不同的是赢一局要付钱给对方,输一局对方会给你钱,现在你初始的资金为0,最多能赢几局。
思路:如果赚的钱大于赔的钱,那么每一局都能赢。
否则输的时候就是0:11;赢得时候就是11:9
AC代码:

#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
typedef vector<double> vec;
typedef vector<vec> mat;
const int N_MAX = ;
int in,out,num;
int T; int main() {
scanf("%d", &T);
int k = ;
while (T--) {
k++;
scanf("%d%d%d",&in,&out,&num);
if (out < in) {
printf("Case #%d: %d\n",k,num);
}
else{
int res = ,remain=;
while (num--) {
int pay = (out * - in * );
if (remain <pay ) {//付不起钱,这句要输
remain += in * ;
}
else {
remain-= pay;
res++;
}
}
printf("Case #%d: %d\n", k, res);
}
}
return ;
}
 

hdu Rich Game 6245的更多相关文章

  1. 2015ACM/ICPC亚洲区长春站 A hdu 5527 Too Rich

    Too Rich Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total ...

  2. HDU 5527---Too Rich(贪心+搜索)

    题目链接 Problem Description You are a rich person, and you think your wallet is too heavy and full now. ...

  3. HDU 2391 Filthy Rich (dp)

    题目连接 Problem Description They say that in Phrygia, the streets are paved with gold. You're currently ...

  4. Too Rich HDU - 5527 (贪心+dfs)

    Too Rich Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total ...

  5. HDU 5527 Too Rich

    Too Rich Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total ...

  6. hdu 2391 Filthy Rich

    单纯dp 水一 处理时间点,第一行和第一列特殊处理: 其余的w[i][j]=show(w[i-1][j-1],w[i-1][j],w[i][j-1]); <span style="fo ...

  7. 【算法系列学习】HDU 5527 Too Rich贪心

    http://www.cnblogs.com/AOQNRMGYXLMV/p/4934747.html #include<iostream> #include<cstdio> # ...

  8. HDU 5527 Too Rich 贪心

    题意: 有\(10\)种面值为\(1, 5, 10, 20, 50, 100, 200, 500, 1000, 2000\)的纸币,现在你要选最多的数量凑成\(p\)块钱. 分析: 同样分析问题的反面 ...

  9. HDU 5527:Too Rich(DFS+贪心)***

    题目链接 题意 给出p块钱,现在要用十种硬币凑出,每种硬币有c[i]个,问最多能用多少个硬币. 思路 首先确定,对于每个硬币就是能用小的替换就不用大的. 所以,可以先把硬币尽量用小的替换,如果小的不够 ...

随机推荐

  1. c++question 004 c++基本数据类型有哪些?

    (1)signed int类型 整数型 占内存4个字节 一个字节byte 占8个二进制位 一个整型就占32位 (2)short int  短整型 占内存2个字节 一个短整型占16位 (3)long i ...

  2. 自己写一个Promise

    参考Promise 的  官方规范  https://promisesaplus.com/ Promise 其实就是一个状态机 它只有两种状态变化 pending    =>   fulfill ...

  3. Java是什么?我们为什么要学习Java?

    Dear All: 首先请允许我为大家介绍下什么是Java?,我们为什么要学Java? 1.Java名字的由来 : Java名字的由来,实际上是一个有趣的故事,我们所见到的Java标志,总是一杯热咖啡 ...

  4. 16.2--Jenkins+Maven+Gitlab+Tomcat 自动化构建打包、部署

    分类: Linux服务篇,Linux架构篇   一.环境需求 本帖针对的是Linux环境,Windows或其他系统也可借鉴.具体只讲述Jenkins配置以及整个流程的实现. 1.JDK(或JRE)及J ...

  5. Laravel 打印已执行的sql语句

    打开app\Providers\AppServiceProvider.PHP,在boot方法中添加如下内容 5.2以下版本 // 先引入DB use DB; // 或者直接使用 \DB:: DB::l ...

  6. SSM(Spring+Spring MVC+Mybatis)开发前台后功能完整的java开源博客管理系统

    项目描述 本项目通过SSM(SpringMVC+Mybatis+Spring)框架编写的一个人博客管理系统,使用hexo主题,以及MAVEN进行对项目管理,并且前端具有粒子和点击爱心效果.后端的页面框 ...

  7. 43.VUE学习之--组件之使用.sync修饰符与computed计算属性超简单的实现美团购物车原理

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. pandas库Series类型与基本操作

    pandas读取excel的类型是dataFrame,然后提取每一列是一个Series类型 Series类型包括index和values两部分 a = pd.Series({'a':1,'b':5}) ...

  9. mysql双机热备实现

    说明 机器A:(172.16.1.251),机器B:(172.16.1.252) 两台机器都创建数据库web:create database hello default charset utf8; 实 ...

  10. HUD:3746-Cyclic Nacklace(补齐循环节)

    Cyclic Nacklace Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Pro ...