2014ACM集训13级PK赛2-Javabeans
2014-03-09 22:09
309 查看
Description
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
Sample Output
1223
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
4 1 2 3 4
Sample Output
1223
#include <stdio.h> int main() { int N; int i; scanf ("%d",&N); while (N--) { int n; int ans = 1; scanf ("%d",&n); int s; while (1) { if (ans == 1) n = n / 2 + 1; else n = (n - 1) / 2 + 1; if (n == 1) { s = 0; break; } if (n == 2) { s = 1; break; }else if (n == 3) { s = 2; break; } ans++; } printf ("%d\n",s + ans); } return 0; }
相关文章推荐
- 2014ACM集训13级PK赛4-Light Bulb
- 2014ACM集训13级PK赛3-Draw Something Cheat
- 2014ACM集训13级PK赛3-Modular Inverse
- 2014ACM集训13级PK赛5- Accurately Say "CocaCola"!
- 2014ACM集训13级PK赛3-Yet Another Story of Rock-paper-scissors
- 2014ACM集训13级PK赛3-Break Standard Weight
- 2014ACM集训13级PK赛5-Easy Task
- 2014ACM集训13级PK赛5-Faster, Higher, Stronger
- 2014ACM集训13级PK赛2-Who is Older?
- 2014ACM集训13级PK赛3-Friends
- 2014ACM集训13级PK赛5-Give Me the Number
- 2014ACM集训13级PK赛2-Somali Pirates
- 2014ACM集训13级PK赛3-Hard to Play
- 2014ACM集训13级PK赛2-An Awful Problem
- 2014ACM集训13级PK赛3-Java Beans
- 2014ACM集训13级PK赛2-Wu Xing
- 2014ACM集训13级PK赛2-Ordinal Numbers
- 2014ACM集训13级PK赛4-Second-price Auction
- 2014ACM集训13级PK赛2-Conic Section
- 2014ACM集训13级PK赛4-80ers' Memory