Codeforces Round #236 (Div. 2) A. Nuts
来源:互联网 发布:淘宝退货规则大全 编辑:程序博客网 时间:2024/04/30 19:33
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.
题意:一个盒子最多可以分k份,每份放v个nut,现有b次分盒子的机会(一个盒子本来只有一个区域,每分一次区域+1)目标:有a个nut,最少要多少个盒子才能装完。
思路:水题,贪心AC(其实这算不算贪心?+_+~)
Accepted15 ms0 KB
#include <stdio.h>#include <stdlib.h>int main(){ int k, a, b, v, sec, t=0; scanf("%d%d%d%d", &k, &a, &b, &v); while(a > 0) { sec = 1; while(b > 0 && sec < k) { sec++;b--; } a -= sec*v; t++; } printf("%d\n",t); return 0;}
- Codeforces Round #236 (Div. 2) A. Nuts
- Codeforces Round #236 (Div. 2) A. Nuts
- codeforces Round #236(DIV 2)A. Nuts
- codeforces Round #236(DIV 2)A. Nuts(数学类计算题)
- Codeforces Round #332 (Div. 2) E. Sandy and Nuts
- Codeforces Round #236 (Div. 2)A
- Codeforces round #236Div.2--A;B
- Codeforces Round #236 (Div. 2)------A,B
- codeforces round #236 div.2 A
- CodeForces 402A 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++
- win7 右下角显示时间日期
- cogs 数列
- eclipse的快捷键
- j2ee环境搭建
- 分享TopCoder的一道题目和个人答案
- Codeforces Round #236 (Div. 2) A. Nuts
- s3c2440系统时钟
- matlab size
- 【机器学习系列】皮尔逊相关系数
- Android提供的LruCache类简介
- 排序算法总结-插入排序、希尔排序、堆排序、快速排序
- 我的博客地址 www.krabs.co
- 如何让recv函数有点脾气?(让你知道select函数的威力)
- 链表操作