TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

The farming games on Facebook are so popular recent times. Everybody gets used to play ‚Farmville‛, ‚Country Story‛, or ‚Restaurant City‛ on Facebook while they are playing or talking through the Internet. Imagine that managing your own farm, just putting yourself in an extremely different agricultural lifestyle far from cities. Most of the games run like this: You grow the plants; you sell these plants, then you buy new plants with a higher level, and do it all over again.


It about Moon Festival, the game master of the Farm decides to give presents to everybody who spent most of their daily life on the game. It's a new type of plant called ‚"Super Sunflower". They grow up, gain levels and duplicate themselves day by day. What a powerful plant! In addition, suppose a super sunflower meets level k today. Then on the next day, it’ll duplicate itself to d new super sunflowers (with level k) and then increase the original sunflower’s level by one. This d is called the growing degree.


For example, suppose we grow a level one super sunflower at Day 0, and the growing degree d = 2.




So after Day 2, we get one level 3 sunflower, four level 2 sunflowers and four level 1 sunflowers.


Game Master decides to give the player a sunflower per day. A diligent guy Godgunman spend a lot of time on Farm, so he may get a plant of sunflower with level one per day. So Godgunman starts to think, at the n’th day, how many sunflowers are there in his farm? It will be too many to count, Godgunman thought. So he decides to focus to count the number of sunflowers with same level. Can you tell him at what level it will have the maximum number of sunflowers?

Input Format

There will be several test cases in the input file, and the input terminates by EOF. For each test case it contains two integers d, n (1< d, n ≦ 20000).

Output Format

For each test case please output the desired number mentioned above in the description. If there are more than one desired number, output the minimum one.
請將輸出的答案減一...

Sample Input 1

2 2
1 5

Sample Output 1

0
2

Hints

Problem Source

Migrated from old NTUJ.

ttcpc2009 problem 8

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 3000 65536 200