【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) = ...
随机推荐
- HDU 5102 The K-th Distance
题意:给你n-1条边,然后没两个节点的距离按照递增的顺序,求出前k项的和. 官方题解: 把所有边(u,v) 以及(v,u)放入一个队列,队列每弹出一个元素(u,v),对于所有与u相邻的点w,如果w!= ...
- AC日记——信息传递 洛谷 P2661 (tarjan求环)
题目描述 有n个同学(编号为1到n)正在玩一个信息传递的游戏.在游戏里每人都有一个固定的信息传递对象,其中,编号为i的同学的信息传递对象是编号为Ti同学. 游戏开始时,每人都只知道自己的生日.之后每一 ...
- NGUI国际化 多语言
相关组件 NGUI的本地化操作相关的组件 Localization UILocalize Language Selection 主要部分 在需要本地化的UILabel上绑定UILocalize,填写K ...
- 05JavaIO详解_仿照IO源码自己去实现一个IO流(为了加深印象,本身没有价值)
版本会越来越难: 版本1:只写一个read方法 package com.guigu.shen.InputStream; import java.io.IOException; import java. ...
- 超详细图解:自己架设NuGet服务器
原文:http://diaosbook.com/Post/2012/12/15/setup-private-nuget-server NuGet 是.NET程序员熟知的给.NET项目自动配置安装lib ...
- 微服务架构:Eureka集群搭建
版权声明:本文为博主原创文章,转载请注明出处,欢迎交流学习! 服务注册.发现是微服务架构的关键原理之一,由于微服务架构是由一系列职责单一的细粒度服务构成的网状结构,服务之间通过轻量机制进行通信,这就必 ...
- 什么是json
http://www.ruanyifeng.com/blog/2009/05/data_types_and_json.html http://edu.51cto.com/lesson/id-71123 ...
- CHAP认证原理
整个过程就是PPP协商过程,分三步:LCP.认证.NCP. 一 协议概述 PPP包含以下两个层次的协议: ·链路控制协议(LCP):负责建立.配置和测试数据链路连接 ·网络控制协议(NCP):负责建立 ...
- Binary Search Tree Iterator
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the ro ...
- PHP基础18:require和include
<?phph //1.通过 include 或 require 语句,可以将 PHP 文件的内容插入另一个 PHP 文件(在服务器执行它之前) //include 和 require 语句是相同 ...