Codeforces Round #236 (Div. 2)A
来源:互联网 发布:最早截止时间优先算法 编辑:程序博客网 时间:2024/05/01 04:12
You have a nuts and lots of boxes. The boxes have a wonderful feature: if you put x (x ≥ 0) divisors (the spacial bars that can divide a box) to it, you get a box, divided into x + 1 sections.
You are minimalist. Therefore, on the one hand, you are against dividing some box into more than k sections. On the other hand, you are against putting more than v nuts into some section of the box. What is the minimum number of boxes you have to use if you want to put all the nuts in boxes, and you have b divisors?
Please note that you need to minimize the number of used boxes, not sections. You do not have to minimize the number of used divisors.
The first line contains four space-separated integers k, a, b, v (2 ≤ k ≤ 1000; 1 ≤ a, b, v ≤ 1000) — the maximum number of sections in the box, the number of nuts, the number of divisors and the capacity of each section of the box.
Print a single integer — the answer to the problem.
3 10 3 3
2
3 10 1 3
3
100 100 1 1000
1
#include <cstdio>#include<cmath>#include<cctype>#include<cstring>#define MAX 101int k,a,b,v;int main(){ freopen("input.txt","r",stdin); while(scanf("%d%d%d%d",&k,&a,&b,&v)!=EOF) { int count=0; if(a%v==0)count=a/v;else count=a/v+1; if(k==1)printf("%d\n",count); if(k>=count&&b>=count-1)printf("1\n"); else { int ok=1,n=0,s=0,sum=0; for(int i=1;i<=b;i++) { if(ok)n++; ok=0;s++; if(i%(k-1)==0) { ok=1; sum+=k; s=0; if(sum==count)break; } if(sum+s+1==count)break; } if(s)sum+=s+1; n+=count-sum; printf("%d\n",n); } } return 0;}
- Codeforces Round #236 (Div. 2) A. Nuts
- Codeforces Round #236 (Div. 2)A
- Codeforces round #236Div.2--A;B
- Codeforces Round #236 (Div. 2) A. Nuts
- Codeforces Round #236 (Div. 2)------A,B
- codeforces round #236 div.2 A
- codeforces Round #236(DIV 2)A. Nuts
- Codeforces Round #236 (Div. 2) B. Trees in a Row
- codeforces Round # 236(DIV 2)B. Trees in a Row
- Codeforces Round #236 (Div. 2)__Trees in a Row
- Codeforces Round #236 (Div. 2) B. Trees in a Row
- Codeforces Round #236 (Div. 2)A(贪心、数学)
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #174 (Div. 2) Problem A
- Codeforces Round #173 (Div. 2) A.Bit++
- Codeforces Round #181 (Div. 2) A题
- Codeforces Round #184 (Div. 2) A题
- Codeforces Round #185 (Div. 2)--A,B
- java删除文件(单个文件,文件夹,子文件夹) 20090812(jsp+servlet+access)
- Linux下重要日志文件及查看方式
- 2012蓝桥杯预赛题-夺冠概率
- 002_021 Python 动态改变Python的搜索路径
- codeforces Round # 236(DIV 2)B. Trees in a Row
- Codeforces Round #236 (Div. 2)A
- Spring MVC中各个filter的用法
- 设计模式学习之——六大设计原则之四:接口隔离原则
- HDFS余额不足之时
- 从11月11号开始我要将我儿时的梦想初步完成(2009年的回忆)
- Spring框架之Filter应用
- [2014-3-17]字符和字符串处理
- 浅析C++ cout语句执行过程
- CF236 B. Trees in a Row