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 ...
随机推荐
- Python 异常相关参考
Python所有的异常都是从BaseException类派生的,常见的错误类型和继承关系如下: BaseException +-- SystemExit +-- KeyboardInterrupt + ...
- Nodejs_day02
Nodejs的事件模块 var events = require('events'); var eventEmitter = new events.EventEmitter();//创建EventEm ...
- Java核心 --- 泛型
CoreJava 泛型 java泛型的出现避免了强制类型转换,便于代码更好的被阅读 本文的写作参照了张孝祥的泛型介绍:http://www.itcast.cn/news/dbfd20f1/f4b1/4 ...
- 基于OSGI.Net的图形界面系统
在2013年的十月份有幸接触了osgi.net和iopenworks的创始人,了解和学习的插件式开发,开始了后台数据的处理生涯. 第一个有图形界面的系统——智能农业的环境监测系统,其实在这个系统中所有 ...
- SAS、R以及SPSS的比较__统计语言大战
- effective c++:对象的赋值运算
operator 中处理”自我赋值“ operator=操作符缺省情况下返回引用——TYPE& TYPE::operator=(const TYPE&),原因很简单,operator= ...
- vmware设置centos虚拟机nat联网(转载)
今天在vmware虚拟主机中安装hearbeat,为了使用最新的版本,选用编译安装了.在编译过程中,需要连接被墙的网站下载文件,那只能用vpn,但我使用的是桥接方式联网,使用不了真实主机的vpn,于是 ...
- Systemd Unit文件中PrivateTmp字段详解-Jason.Zhi
如下图,在开发调试的时候会遇到这么一个问题. file_put_contents时,$tmp_file显示的目标文件是/tmp/xxx.而这个文件实际放在linux的目录却是/tmp/systemd- ...
- LINQ标准查询操作符(二)——Join、GroupJoin、GroupBy、Concat、
四.联接操作符 联接是指将一个数据源对象与另一个数据源对象进行关联或者联合的操作.这两个数据源对象通过一个共同的值或者属性进行关联. LINQ有两个联接操作符:Join和GroupJoin. 1. J ...
- 让CSS3给你的文字加上边框宽度,并实现镂空效果
这次,我主要向大家介绍一下CSS3下的-webkit-text-stroke属性,并分享几个用该属性制作的镂空文字效果. 1.-webkit-text-stroke属性简介 CSS边框的一个不足就是只 ...