【CodeForces 625A】Guest From the Past
题意
一升奶可以花费a元,也可以用b元买然后获得c元,一开始有n元,求最多买多少升奶。
分析
贪心,如果b-c<a,且n≥b,那就买b元的,n先减去b再看看够买多少瓶,然后再+1瓶,余款再购买a元的。
代码
#include<cstdio>
unsigned long long n,a,b,c,ans;
int main(){
scanf("%lld%lld%lld%lld",&n,&a,&b,&c);
if(b-c<a && n>=b){
ans=(n-b)/(b-c)+;
n-=(b-c)*ans;
}
ans+=n/a;
printf("%lld",ans);
return ;
}
【CodeForces 625A】Guest From the Past的更多相关文章
- 【15.07%】【codeforces 625A】Guest From the Past
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【13.91%】【codeforces 593D】Happy Tree Party
time limit per test3 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 707E】Garlands
[题目链接]:http://codeforces.com/contest/707/problem/E [题意] 给你一个n*m的方阵; 里面有k个联通块; 这k个联通块,每个连通块里面都是灯; 给你q ...
- 【codeforces 707C】Pythagorean Triples
[题目链接]:http://codeforces.com/contest/707/problem/C [题意] 给你一个数字n; 问你这个数字是不是某个三角形的一条边; 如果是让你输出另外两条边的大小 ...
- 【codeforces 709D】Recover the String
[题目链接]:http://codeforces.com/problemset/problem/709/D [题意] 给你一个序列; 给出01子列和10子列和00子列以及11子列的个数; 然后让你输出 ...
- 【codeforces 709B】Checkpoints
[题目链接]:http://codeforces.com/contest/709/problem/B [题意] 让你从起点开始走过n-1个点(至少n-1个) 问你最少走多远; [题解] 肯定不多走啊; ...
- 【codeforces 709C】Letters Cyclic Shift
[题目链接]:http://codeforces.com/contest/709/problem/C [题意] 让你改变一个字符串的子集(连续的一段); ->这一段的每个字符的字母都变成之前的一 ...
- 【Codeforces 429D】 Tricky Function
[题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...
随机推荐
- 第8课 goto 和 void 分析
1. 遭人遗弃的goto (1)高手潜规则:禁用goto (2)项目经验:程序质量与goto出现的次数成反比 (3)最后的判决:将goto打入冷宫(1)循环语句的基本工作方式 [实例分析]goto副作 ...
- 06SpringMvc_适配器
适配器的主要功能是去找控制器.Action实现了什么接口 本文案例实现的功能是:在页面上输入中文名字,然后在另外一个网页上显示出来. 案例结构:
- ASP.NET MVC3 Model验证总结(转)
推荐: ASP.NET MVC的Model元数据与Model模板:预定义模板 http://www.cnblogs.com/artech/archive/2012/05/02/model-meta ...
- Linux Linux程序练习十二(select实现QQ群聊)
//头文件--helper.h #ifndef _vzhang #define _vzhang #ifdef __cplusplus extern "C" { #endif #de ...
- pandas 前后行操作
一.前后行满足条件 问题: 各位老师好,我有一个dataframe 产品 数据1 数据2 A 1 2 B 4 5 C 6 3 我想找出比如这一行数据1>数据2 AND 数据1的上一行3 AND ...
- 机器学习算法 Python & R速查表
- scrapy 爬取自己的博客
定义项目 # -*- coding: utf-8 -*- # items.py import scrapy class LianxiCnblogsItem(scrapy.Item): # define ...
- 【兄弟连】2016高洛峰新版PHP培训视频教程
[兄弟连]2016高洛峰新版PHP培训视频教程 视频部分目录: 下载地址:http ...
- windows2003 单网卡 搭建vpn ,windows 2008 R2 类似吧。网上转的,自己加了点经验总结
先说说可能的坑,也就是我自己搭建的时候碰到的问题. 其实搭建起来很简单,我不知道我总结的对还是不对,但是按下面这样操作做绝对能搭好!因为我就是按这样搭起来的,但是我发现,好像pptp已经被墙了,我也不 ...
- Windows Phone & Windows App应用程序崩溃crash信息抓取方法
最近有用户反馈,应用有崩溃的情况,可是本地调试却无法重现问题,理所当然的,我想到了微软的开发者仪表盘,可以查看一段时间内的carsh记录,不过仪表盘生成carsh记录不是实时的,而且生成的报告查看非常 ...