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. 模态框获取内容jQuery

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

  2. python 进度条 打印

  3. python字典按照k,v来排序

    按照 k 排序 按照 v 排序

  4. day 52 Django基础一之web框架的本质

    Django基础一之web框架的本质   django第一天 本节目录 一 web框架的本质及自定义web框架 二 模板渲染JinJa2 三 MVC和MTV框架 四 Django的下载安装 五 基于D ...

  5. poj 3258 跳房子问题 最大化最小值

    题意:奶牛跳房子,从n块石头中移除M块,使得间距最小的最大值?思路:“转换” 从N块中选择n-m块使得两两之间的间距尽可能大 c(d) 是间距最大的满足条件,即第一块 放在 xi的位置 下一块就要放在 ...

  6. 1497: [NOI2006]最大获利(最大权闭合子图)

    1497: [NOI2006]最大获利 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 5503  Solved: 2673 Description 新的技 ...

  7. synchronized 基本用法

    常见三种使用方式 1)普通同步方法,锁是当前实例:2)静态同步方法,锁是当前类的Class实例,Class数据存在永久代中,是该类的一个全局锁:3)对于同步代码块,锁是synchronized括号里配 ...

  8. windows下虚拟环境中配置MySQL-python错误问题

    下载mysql 下载mysql-python 这两步基本没有问题怪就怪的 MySQL-python-1.2.3.win-amd64-py2.7 文件只能安装到python27  路径下 然后在虚拟环境 ...

  9. laravel5.2总结--响应

      1 基本响应 1.1 返回一个字符串,指定的字符串会被框架自动转换成 HTTP 响应. Route::get('/', function () { return 'Hello World'; }) ...

  10. LuffyCity-MySQL综合练习50实例

    1.请创建如下表,并添加相应约束: 2.自行构造测试数据: 新建数据库 创建表 构造测试数据 #Step1-创建数据库LuffyCity_MySQL; #CREATE DATABASE LuffyCi ...