国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 宝鸡市| 额济纳旗| 乡城县| 平江县| 即墨市| 普陀区| 赤城县| 辛集市| 长岭县| 乡宁县| 库伦旗| 庄浪县| 甘谷县| 鄂伦春自治旗| 高清| 顺义区| 苍梧县| 呼玛县| 金沙县| 临清市| 鄂尔多斯市| 岚皋县| 乐清市| 错那县| 阿鲁科尔沁旗| 宣化县| 清河县| 巨野县| 鸡西市| 武强县| 当雄县| 乌海市| 宾川县| 驻马店市| 新密市| 巴塘县| 洪湖市| 长乐市| 潢川县| 泌阳县| 长子县|