Codeforces Round #342 (Div. 2) A - Guest From the Past 数学
A. Guest From the Past
题目连接:
http://www.codeforces.com/contest/625/problem/A
Description
Kolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the details of buying this delicious drink. One day, as you probably know, he found himself in year 2084, and buying kefir there is much more complicated.
Kolya is hungry, so he went to the nearest milk shop. In 2084 you may buy kefir in a plastic liter bottle, that costs a rubles, or in glass liter bottle, that costs b rubles. Also, you may return empty glass bottle and get c (c < b) rubles back, but you cannot return plastic bottles.
Kolya has n rubles and he is really hungry, so he wants to drink as much kefir as possible. There were no plastic bottles in his 1984, so Kolya doesn't know how to act optimally and asks for your help.
Input
First line of the input contains a single integer n (1 ≤ n ≤ 1018) — the number of rubles Kolya has at the beginning.
Then follow three lines containing integers a, b and c (1 ≤ a ≤ 1018, 1 ≤ c < b ≤ 1018) — the cost of one plastic liter bottle, the cost of one glass liter bottle and the money one can get back by returning an empty glass bottle, respectively.
Output
Print the only integer — maximum number of liters of kefir, that Kolya can drink.
Sample Input
10
11
9
8
Sample Output
2
Hint
题意
你有n元钱,你可以花a元去买一瓶水,可以花B元钱买可以退的水,退了可以得到C元
问你最多喝多少瓶
题解:
1.首先我们可以全部都用a买
2.全部都用b买,卖完再退回去,剩下的钱让a买
没了,就这两种情况,判断一下哪边大就好了
代码
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,c;
int main()
{
cin>>n>>a>>b>>c;
if(a<=b-c||n<b)
cout<<n/a;
else
cout<<(n-b)/(b-c)+1+((n-b)%(b-c)+c)/a;
}
Codeforces Round #342 (Div. 2) A - Guest From the Past 数学的更多相关文章
- Codeforces Round #342 (Div. 2) A. Guest From the Past(贪心)
传送门 Description Kolya Gerasimov loves kefir very much. He lives in year 1984 and knows all the detai ...
- Codeforces Round #342 (Div. 2)-A. Guest From the Past
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Codeforces Round #342 (Div. 2)
贪心 A - Guest From the Past 先买塑料和先买玻璃两者取最大值 #include <bits/stdc++.h> typedef long long ll; int ...
- Codeforces Round #342 (Div. 2) D. Finals in arithmetic 贪心
D. Finals in arithmetic 题目连接: http://www.codeforces.com/contest/625/problem/D Description Vitya is s ...
- Codeforces Round #342 (Div. 2) C. K-special Tables 构造
C. K-special Tables 题目连接: http://www.codeforces.com/contest/625/problem/C Description People do many ...
- Codeforces Round #342 (Div. 2) B. War of the Corporations 贪心
B. War of the Corporations 题目连接: http://www.codeforces.com/contest/625/problem/B Description A long ...
- Codeforces Round #342 (Div. 2) A
A. Guest From the Past time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Codeforces Round #342 (Div. 2) E. Frog Fights set 模拟
E. Frog Fights 题目连接: http://www.codeforces.com/contest/625/problem/E Description stap Bender recentl ...
- Codeforces Round #342 (Div. 2) D. Finals in arithmetic(想法题/构造题)
传送门 Description Vitya is studying in the third grade. During the last math lesson all the pupils wro ...
随机推荐
- delphi TClientDataSet 保存到XML
procedure ExPortNodeQuantifyComponent1(aCDS: TClientDataSet; aCurrNode: TXMLNode); var mStream: TMem ...
- java 学习资料
最近一直在从java基础开始学习java,感觉个人学习思路还是比较混乱的. 看到Java工程师成神之路中介绍了需要学习的知识点,并在<成神之路系列文章>中分章分节的开始介绍其中所有的知识点 ...
- windows系统下Python环境的搭建及Selenium的安装
1.首先访问http://www.python.org/download/去下载最新的python版本: 2.下载安装包,一路安装完毕: 3.为计算机添加安装目录搭到环境变量,如图把python的安装 ...
- 为我所用之Monkey
文章由来:有朋友问到Monkey的使用的问题,就整理一下Monkey的基本使用,以备后用查询. Monkey是一Android中的一个命令行工具,eclipse中有自带此工具,可以运行在模拟器以及真实 ...
- python中隐式的内存共享
在python中,基本上使用的是引用,那么就会造成一个隐式的内存共享,特别是在容器对象中,例如list,dictionary 对于不可变对象,是不会造成隐式的内存共享情况,如下所示: >> ...
- hadoop-1.2.0 eclipse插件编译
linux.windows下通用,亲测. 下面以window为例,假设:hadoop工程目录位于D:\work\eclipse64\hadoop-1.2.0.1.3.0.0,eclipse安装目录为E ...
- JavaScript 继承方式详解
js继承的概念 js里常用的如下两种继承方式: 原型链继承(对象间的继承)类式继承(构造函数间的继承) 由于js不像java那样是真正面向对象的语言,js是基于对象的,它没有类的概念.所以,要想实现继 ...
- JNLP + Applet + Bouncy Castle
http://stackoverflow.com/questions/4275005/jnlp-applet-bouncy-castle ——————————————————————————————— ...
- rdlc Report Viewer Configuration Error
主要是web.config没有配置 方法参考http://msdn.microsoft.com/zh-cn/library/ms251661.aspx
- POP3&SMTP&IMAP
[POP3&SMTP&IMAP] IMAP是什么? IMAP,即Internet Message Access Protocol(互联网邮件访问协议),您可以通过这种协议从邮件服务器上 ...