Back
Close

King's generosity

Statement

 Goal

The king wants to share his wealth with a certain number of people N in his kingdom, so he has provided a certain amount of gold coins A. Knowing that each person who receives gold coins wants twice as much as the person before him (and that the first person receives only one gold coin), has the king provided enough gold coins to give to the N people in his kingdom.

ex :

there are 3 people
the king has 15 gold coins

person 1 : 1 gold coin
person 2 : 2 gold coins
person 3 : 4 gold coins

--> 1+2+4 = 7 <= 15, the king has enough gold coins
Input
the number of people N to whom the king must give money
the number of gold coins A that the king has planned to give to his people
Output
True, if the king has enough gold coins to give to everyone N.
Otherwise, the number of people who received the gold coins they asked for.
Constraints
N is integer, 0<= N <= 1000
A is integer, 0<= A <= 1000000
Example
Input
3
15
Output
True

Game modes
Fastest, Shortest

Test cases
Test 1 Test
Input
3 15
Output
True

Validator 1 Validator
Input
5 127
Output
True

Test 2 Test
Input
120 12000
Output
13

Validator 2 Validator
Input
17 131000
Output
16

Test 3 Test
Input
12 4095
Output
True

Validator 3 Validator
Input
6 63
Output
True

Test 4 Test
Input
0 0
Output
True

Validator 4 Validator
Input
0 0
Output
True

Test 5 Test
Input
1 0
Output
0

Validator 5 Validator
Input
1 0
Output
0

Solution language

Solution

Stub generator input