codeforce 402A - Nuts
来源:互联网 发布:云计算 教育行业 编辑:程序博客网 时间:2024/06/08 10:53
题目链接:http://codeforces.com/problemset/problem/402/A
题目大意:每个盒子可由x块挡板分为x+1节,但每个盒子不能超过k节,每节不能放超过v个坚果,现在有a个坚果,b块隔板,问最多需要多少个盒子。
题目分析:模拟。
代码参考:
#include<map>#include<set>#include<cmath>#include<queue>#include<stack>#include<cstdio>#include<string>#include<cstring>#include<sstream>#include<iostream>#include<algorithm>#include<functional>using namespace std;int main(){ int k, a, b, v, cnt; while(~scanf("%d%d%d%d", &k, &a, &b, &v)) { cnt = 0; while(b>=k-1 && a>=k*v)//每个盒子最多放k-1块挡板,k*v个坚果,如果此时还多余k-1快挡板并且还多余k*v个坚果 { b -= k-1;//每次用掉k-1块挡板 a -= k*v;//每次放入k*v个坚果 cnt++;//每次用掉一个盒子 } if(b>0 && a>0)//如果还有剩余的挡板并且还有多余坚果 { a -= (b+1)*v;//用掉(b+1)*v个坚果(也可能不足v个) cnt++;//但肯定还是要用掉一个盒子 } while(a>0)//如果仍然有多余 { a -= v;//每次用掉v个坚果(最后一次可能不足v个) cnt++;//但肯定还是要用掉一个盒子 } printf("%d\n", cnt); } return 0;}
0 0
- codeforce 402A - Nuts
- CF 402A - Nuts
- CodeForces 402A Nuts
- Codeforence 402 A. Nuts
- code forces 402A Nuts
- A. Nuts
- CodeForces 402A Nuts (二分)
- Nuts
- Codeforce A
- Codeforces Round #236 (Div. 2) A. Nuts
- Codeforces Round #236 (Div. 2) A. Nuts
- codeforces Round #236(DIV 2)A. Nuts
- Codeforce # A Plug-in
- codeforce 2A Winner
- Contest on codeforce A
- codeforce 11 04 A
- codeforce小水题--A. Presents
- Codeforce #145A Cinema
- 困惑:MySQL大数据库导入导出的问题
- SQL Server 常用SQL总结
- Android判断系统前后台应用和服务之ActivityManager
- V4L2 API详解 <二> Camera详细设置
- Java中的Enum的使用与分析
- codeforce 402A - Nuts
- 深入Java单例模式
- [Android]反编译apk + eclipse中调试smali
- android HorizontalScrollView讲解
- java---文件分隔符
- wpf combox 绑定值和设定值
- 双色LED灯一些特性研究
- 如何判断百度query需求来评判网页质量好坏
- meanShift算法介绍