Problem Statement
This problem statement contains superscripts that may not display properly outside the applet.
Kitayuta Mart is the largest supermarket in Shuseki Kingdom, offering a great variety of food and household products. The main products are fruits, especially apples. The price system is a little special: the original price of an apple is K yen (the currency of the kingdom). However, if a customer wants to buy more than one apple, the second apple will cost 2*K yen, the third apple will cost 22*K yen, and so on. In general, if a customer is buying n apples, the actual price of the i-th (1 <= i <= n) apple will be 2i-1*K yen.
Lun the dog loves apples. She has just bought some number of apples at Kitayuta Mart. The prices of those apples were calculated using the above formula. The total she paid for her apples was T yen. You are given two
Definition
- Class:
- KitayutaMart2
- Method:
- numBought
- Parameters:
- int, int
- Returns:
- int
- Method signature:
- int numBought(int K, int T)
- (be sure your method is public)
Constraints
- K will be between 80 and 160, inclusive.
- T will be between 80 and 163,680, inclusive.
- The input will be such that the answer exists and is unique.
Examples
100
100
Returns: 1
If she buys only one apple, the price will just be K yen.
100
300
Returns: 2
The second apple will cost 2*100 = 200 yen, for the total price of 100 + 200 = 300 yen.
150
1050
Returns: 3
150 + 2*150 + 22*150 = 150 + 300 + 600 = 1050.
160
163680
Returns: 10
80
80
Returns: 1
125
125
Returns: 1
129
129
Returns: 1
139
139
Returns: 1
157
157
Returns: 1
83
249
Returns: 2
86
258
Returns: 2
106
318
Returns: 2
112
336
Returns: 2
114
342
Returns: 2
85
595
Returns: 3
108
756
Returns: 3
138
966
Returns: 3
155
1085
Returns: 3
158
1106
Returns: 3
83
1245
Returns: 4
87
1305
Returns: 4
98
1470
Returns: 4
110
1650
Returns: 4
157
2355
Returns: 4
116
3596
Returns: 5
119
3689
Returns: 5
138
4278
Returns: 5
154
4774
Returns: 5
158
4898
Returns: 5
94
5922
Returns: 6
141
8883
Returns: 6
143
9009
Returns: 6
145
9135
Returns: 6
151
9513
Returns: 6
81
10287
Returns: 7
82
10414
Returns: 7
92
11684
Returns: 7
130
16510
Returns: 7
160
20320
Returns: 7
106
27030
Returns: 8
119
30345
Returns: 8
127
32385
Returns: 8
157
40035
Returns: 8
159
40545
Returns: 8
80
40880
Returns: 9
82
41902
Returns: 9
120
61320
Returns: 9
155
79205
Returns: 9
158
80738
Returns: 9
83
84909
Returns: 10
91
93093
Returns: 10
93
95139
Returns: 10
108
110484
Returns: 10
110
112530
Returns: 10