国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Java > 正文

ZOJ3498-Javabeans

2019-11-06 09:15:31
字體:
供稿:網(wǎng)友

javabeans

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Javabeans are delicious. Javaman likes to eat javabeans very much.

Javaman has n boxes of javabeans. There are exactly i javabeans in the i-th box (i = 1, 2, 3,...n). Everyday Javaman chooses an integer x. He also chooses several boxes where the numbers of javabeans are all at least x. Then he eats x javabeans in each box he has just chosen. Javaman wants to eat all the javabeans up as soon as possible. So how many days it costs for him to eat all the javabeans?

Input

There are multiple test cases. The first line of input is an integer T ≈ 100 indicating the number of test cases.

Each test case is a line of a positive integer 0 < n < 231.

Output

For each test case output the result in a single line.

Sample Input

41234

Sample Output

1223


Author: CAO, PengContest: The 8th Zhejiang PRovincial Collegiate Programming Contest

題意:有n個盒子。第i個盒子有i個javabean,每天可以選擇一個x,然后把盒子里有大于等于x個javabeans里吃掉x個,問最少需要幾天才能吃完。

解題思路:n個盒子,每天吃(n+1)/2個,最多的盒子剩下n/2個

#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <algorithm>#include <cmath>#include <queue>#include <vector>#include <set>#include <stack>#include <map>#include <climits>using namespace std;#define LL long longconst int INF=0x3f3f3f3f;int main(){    int t,n;    scanf("%d",&t);    while(t--)    {        scanf("%d",&n);        int sum=0;        while(n)        {            n/=2;            sum++;        }        printf("%d/n",sum);    }    return 0;}


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 太白县| 永春县| 皋兰县| 灵寿县| 乌兰县| 习水县| 宁安市| 泰州市| 镇坪县| 晋宁县| 庐江县| 克拉玛依市| 福鼎市| 运城市| 元谋县| 克什克腾旗| 沈阳市| 宣恩县| 乌拉特前旗| 都匀市| 体育| 昌黎县| 桐庐县| 新建县| 龙岩市| 莱芜市| 都江堰市| 元阳县| 滨州市| 兴城市| 县级市| 游戏| 神木县| 偃师市| 通渭县| 图们市| 尤溪县| 中阳县| 鄂尔多斯市| 孝感市| 郸城县|