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. 用css去除chrome、safari等webikt内核浏览器对控件默认样式

    有这么一个webkit的私有属性: -webkit-appearance:none; /*去除input默认样式*/ 添加该样式,并且值为'none'时即可取消浏览器对于控件的默认样式. 另外这个属性 ...

  2. 学习笔记(六): Regularization for Simplicity

    目录 Overcrossing? L₂ Regularization Lambda Examining L2 regularization Check Understanding Glossay Ov ...

  3. 八、Shell test 命令

    Shell test 命令 Shell中的 test 命令用于检查某个条件是否成立,它可以进行数值.字符和文件三个方面的测试. 数值测试 参数 说明 -eq 等于则为真 -ne 不等于则为真 -gt ...

  4. WebSocket 详解

    WebSocket 出现前 构建网络应用的过程中,我们经常需要与服务器进行持续的通讯以保持双方信息的同步.通常这种持久通讯在不刷新页面的情况下进行,消耗一定的内存资源常驻后台,并且对于用户不可见.在 ...

  5. 懒人的mysql管理脚本

    最近常用到的命令,太懒不想打太多 1,mysql启动,重启,停止脚本 echo '/usr/local/mysql5/support-files/mysql.server $1'>>/us ...

  6. ZendFramework-2.4 源代码 - 关于MVC - Model层

    所谓的谓词Predicate // ------ 所谓的谓词 ------ // 条件 case.3 $where = new \Zend\Db\Sql\Where(); $expression = ...

  7. 初学js之qq聊天实例

    实现的功能为上图所示,但是每新发送的消息必须显示在最上面. 我实现了两版,样式有是一样的.我们直接看代码. 版本一: <!DOCTYPE html> <html lang=" ...

  8. 动态规划:POJ2576-Tug of War(二维费用的背包问题)

    Tug of War Time Limit: 3000MS Memory Limit: 65536K Description A tug of war is to be arranged at the ...

  9. 【Todo】 cygwin下emacs中M-x shell 中出现乱码

  10. Kali 中文家目录改英文目录

    中文版Kali装好之后,家目录会中文显示,不便操作 root@kali:~# ls -l drwxr-xr-x root root .0K 7月 : 公共 drwxr-xr-x root root . ...