Rich Game_模拟+思维+2018_3_18

7 篇文章 0 订阅
3 篇文章 0 订阅


Rich Game

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


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.
1T105.
1X,Y,K1000.
 

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.
 

Source
 

Recommend
liuyiding
 

#include<bits/stdc++.h> 
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	for(int z=1;z<=n;z++){
		int x,y,k;
		scanf("%d%d%d",&x,&y,&k);
		if(x>y)printf("Case #%d: %d\n",z,k);
		else{
			int mm=11*y-9*x;
			int s=0;
			int l=0;
			for(int i=0;i<k;i++){
				if(s<mm)
				s+=11*x;
				else{
					s-=mm;
					l++;
				}
			}
			printf("Case #%d: %d\n",z,l);
		}
	}
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值