Codeforces Round #342 (Div. 2) 625A Guest From the Past(贪心)
来源:互联网 发布:java自学源代码 编辑:程序博客网 时间:2024/06/06 09:28
题目链接:点击打开链接
塑料瓶牛奶a卢比, 玻璃瓶b卢比, 且玻璃空瓶可以换c元, 问最多可以喝多少牛奶.
玻璃瓶净价是b - c, 如果塑料瓶比净价还便宜, 则均买塑料瓶. 否则尽量买玻璃瓶, 剩下的买塑料瓶.
AC代码:
#include "iostream"#include "cstdio"#include "cstring"#include "algorithm"#include "queue"#include "stack"#include "cmath"#include "utility"#include "map"#include "set"#include "vector"#include "list"#include "string"#include "cstdlib"using namespace std;typedef long long ll;#define X first#define Y secondconst int MOD = 1e9 + 7;const int INF = 0x3f3f3f3f;ll n, a, b, c, ans;int main(int argc, char const *argv[]){cin >> n >> a >> b >> c;if(a < b - c) ans = n / a;else {if(n >= b) {ans = (n - b) / (b - c) + 1;n -= ans * (b - c);}ans += n / a;}cout << ans << endl;return 0;}
1 0
- Codeforces Round #342 (Div. 2) 625A Guest From the Past(贪心)
- Codeforces Round #342 (Div. 2)--A. Guest From the Past
- Codeforces Round #342 (Div. 2)-A. Guest From the Past
- Codeforces Round #342 (Div. 2) A. Guest From the Past(想法)
- Codeforces Round #342 (Div. 2)-A. Guest From the Past(数学)
- CodeForces 625A Guest From the Past
- CodeForces 625A - Guest From the Past
- Codeforces 625 . A Guest From the Past
- CodeForces 625A Guest From the Past
- CodeForces 625A Guest From the Past
- cf#342-A-Guest From the Past-贪心
- Codeforces 625A Guest From the Past 【基础数学】
- CodeForces 625 A. Guest From the Past(水~)
- CodeForces 625A E - Guest From the Past
- 【15.07%】【codeforces 625A】Guest From the Past
- CfRound #342 (Div. 2) Guest From the Past 贪心思维题
- 625A.Guest From the Past
- Codeforces Round #418 (Div. 2) problem A. An abandoned sentiment from past
- Hadoop 排序 SortData
- 软件开发技术:DRY
- Monty Hall Simulations
- 文章标题
- chmod,fchmod,and fchmodat Functions
- Codeforces Round #342 (Div. 2) 625A Guest From the Past(贪心)
- 查找单链表的中间元素
- VMware创建Linux虚拟机
- 时间,在我们手中
- 树莓派 Raspberry Pi SD卡系统备份与还原
- 【JAVA】7、运算符
- 第十章泛型算法
- Codeforces Round #342 (Div. 2) 625B War of the Corporations(stl)
- 数据结构实验之链表七:单链表中重复元素的删除