Codeforence 402 A. Nuts
来源:互联网 发布:知弘美术馆 编辑:程序博客网 时间:2024/06/17 01:00
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
In the first sample you can act like this:
- Put two divisors to the first box. Now the first box has three sections and we can put three nuts into each section. Overall, the first box will have nine nuts.
- Do not put any divisors into the second box. Thus, the second box has one section for the last nut.
In the end we've put all the ten nuts into boxes.
The second sample is different as we have exactly one divisor and we put it to the first box. The next two boxes will have one section each.
这个题目是需要好好看题意的,唉,看题意就花了这么久,自己真是水到家了!!!!!!
#include<iostream>#include<cstdio>#include<cstring>using namespace std;int main(){ int i,j,p; int a,b,k,v; int num; scanf("%d%d%d%d",&k,&a,&b,&v); num=1; int sum=0; while(1) { //printf("%d\n",a); if(a<=0) { // printf("fjdskljfds"); break; // 分完了 } num=1; while(b>0) { if(num<k) { num++; b--; } else break; } a=a-num*v; sum++; } printf("%d\n",sum);}
- Codeforence 402 A. Nuts
- codeforce 402A - Nuts
- CF 402A - Nuts
- CodeForces 402A Nuts
- code forces 402A Nuts
- A. Nuts
- Nineteen Codeforence 393A
- Codeforence 393A
- Codeforence 352A
- Codeforence 337A Puzzles
- CodeForces 402A Nuts (二分)
- Codeforence A. Slightly Decreasing Permutations
- Codeforence 400 A. Inna and Choose Options
- Codeforence 258A. Little Elephant and Bits
- Nuts
- Codeforces Round #236 (Div. 2) A. Nuts
- Codeforces Round #236 (Div. 2) A. Nuts
- codeforces Round #236(DIV 2)A. Nuts
- android ccache 减少编译的时间
- 留言板的问题没有留意到
- 移动App设计的十条建议
- 互联网媒体广告份额上升 传统媒体受影响下降
- P2P技术原理学习
- Codeforence 402 A. Nuts
- CocurrentHashMap和Hashtable的区别
- 六.1体验常成员函数
- org.hibernate.SessionException: Session is closed!
- Android alertDialog
- JavaScript程序设计之级联样式表
- 分数类
- 云端部署JBOSS之穿越网关
- json转换