博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #342 (Div. 2) A - Guest From the Past 数学
阅读量:7213 次
发布时间:2019-06-29

本文共 1481 字,大约阅读时间需要 4 分钟。

A. Guest From the Past

题目连接:

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
using namespace std;long long n,a,b,c;int main(){ cin>>n>>a>>b>>c; if(a<=b-c||n

转载地址:http://aguym.baihongyu.com/

你可能感兴趣的文章
LeetCode – Refresh – Subsets
查看>>
机器学习 LR getA()
查看>>
Leetcode题目:Power of Three
查看>>
scau 1079 三角形(暴力)
查看>>
去除空格
查看>>
Python--matplotlib绘图可视化知识点整理
查看>>
过滤器会拦截 前端页面加载 js文件的请求
查看>>
开源框架bboss v5.0.0 发布
查看>>
SpringMVC中获得HttpRequest对象的方法
查看>>
JSDom——列表选中移动篇
查看>>
使用扩展方法,让菜单也可以Clone
查看>>
标准sql执行顺序
查看>>
docker的目录挂载
查看>>
百度api集合!
查看>>
SPS2003升级MOSS2007时SSO部件错误解决
查看>>
javascript中array常用属性方法
查看>>
linux添加新的swap分区
查看>>
Jquery Easyui与Jquery Bootstrap(Metronic Bootstrap)的简单比较
查看>>
Java核心技术及面试指南 JDBC部分的面试题总结以及答案
查看>>
OCP读书笔记(20) - 复制数据库
查看>>