ZOJ_3568_Exchange for Cola(水题)
来源:互联网 发布:h3c mac地址绑定ip 编辑:程序博客网 时间:2024/06/07 00:52
The Cola company is holding a promotional activity that customers can exchange B bottles of Cola with A caps. Now guinao has N caps. Furthermore, guinao can ask mm to borrow him some caps for any times as long as guinao is able to return the caps borrowed after he has used these caps to exchange Cola without buying any other Cola. Please tell guinao how many number of Cola guinao can drink.
Input
This problem contains multiple test cases. Each case contains one line with three numbers N, A, B, (1 <= N <= 10^9, 1 <= B < A <= 10^9), which have already been mentioned above.
Output
Print exactly one line with the maximal number of Cola guinao can drink by exchanging caps for each test case.
Sample Input
1 2 19 7 2
Sample Output
12
题型:简单题
题意:
可乐公司做活动,可以用a个瓶盖换b瓶可乐。现在guinao有n个盖子,他能够在任何时候跟mm借一些盖子,但是前提是他在换完之后能够将盖子还给mm。问guinao最多能喝到多少瓶可乐。
分析:一次一次模拟,当他还不了借的盖子的时候就break。
代码:
#include<iostream>#include<cstdio>using namespace std;int main(){ long long a,b,n; long long lend; long long ans; while(~scanf("%lld%lld%lld",&n,&a,&b)){ ans=0; lend=0; while(1){ if(n<a){ lend=a-n; n=a; } int t=n; n=n%a+b*(n/a); if(n>=lend) ans+=b*(t/a),n-=lend; else break; } printf("%lld\n",ans); } return 0;}
- ZOJ_3568_Exchange for Cola(水题)
- 1003 Exchange for Cola
- zoj3568 BIT1003 Exchange for Cola
- bit 1003 Exchange for Cola
- BIT 1003 Exchange for Cola
- zoj 3568 Exchange for Cola
- Cola
- 寒假练习 1003 Exchange for Cola
- BIT寒假练习-2013__1003:Exchange for Cola
- 11150 - Cola
- Double Cola
- Cola HDU1495
- Marjar Cola
- 2013寒假练习 1003: Exchange for Cola(2/13更新)
- SOJ-3601(Cola)
- UVa 11150 - Cola
- A. Double Cola
- A. Double Cola
- HDU 4333 Revolving Digits (扩展KMP)
- 从0开始学python:打开编辑文件
- 策略路由以及使用 ip route , ip rule , iptables 配置策略路由实例
- OSG+VS2010+win7环境搭建
- TCP/IP 应用程序的通信连接模式
- ZOJ_3568_Exchange for Cola(水题)
- oracle 三种集合数据类型【varray,嵌套表,联合数组】+record
- 用于自定义数据/结构体的剪切板应用模板类
- Python模块学习 ---- StringIO, cStringIO 内存文件
- C/C++的内存分布
- liunx命令——cp
- Hadoop
- Android中的线程池
- 空缺。。