Statistics

Problem Statement for "KitayutaMart2"

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 ints: K and T. Find and return the number of the apples that Lun has bought. It is guaranteed that K and T are such that the answer exists and is unique.

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

  1. 100

    100

    Returns: 1

    If she buys only one apple, the price will just be K yen.

  2. 100

    300

    Returns: 2

    The second apple will cost 2*100 = 200 yen, for the total price of 100 + 200 = 300 yen.

  3. 150

    1050

    Returns: 3

    150 + 2*150 + 22*150 = 150 + 300 + 600 = 1050.

  4. 160

    163680

    Returns: 10

  5. 80

    80

    Returns: 1

  6. 125

    125

    Returns: 1

  7. 129

    129

    Returns: 1

  8. 139

    139

    Returns: 1

  9. 157

    157

    Returns: 1

  10. 83

    249

    Returns: 2

  11. 86

    258

    Returns: 2

  12. 106

    318

    Returns: 2

  13. 112

    336

    Returns: 2

  14. 114

    342

    Returns: 2

  15. 85

    595

    Returns: 3

  16. 108

    756

    Returns: 3

  17. 138

    966

    Returns: 3

  18. 155

    1085

    Returns: 3

  19. 158

    1106

    Returns: 3

  20. 83

    1245

    Returns: 4

  21. 87

    1305

    Returns: 4

  22. 98

    1470

    Returns: 4

  23. 110

    1650

    Returns: 4

  24. 157

    2355

    Returns: 4

  25. 116

    3596

    Returns: 5

  26. 119

    3689

    Returns: 5

  27. 138

    4278

    Returns: 5

  28. 154

    4774

    Returns: 5

  29. 158

    4898

    Returns: 5

  30. 94

    5922

    Returns: 6

  31. 141

    8883

    Returns: 6

  32. 143

    9009

    Returns: 6

  33. 145

    9135

    Returns: 6

  34. 151

    9513

    Returns: 6

  35. 81

    10287

    Returns: 7

  36. 82

    10414

    Returns: 7

  37. 92

    11684

    Returns: 7

  38. 130

    16510

    Returns: 7

  39. 160

    20320

    Returns: 7

  40. 106

    27030

    Returns: 8

  41. 119

    30345

    Returns: 8

  42. 127

    32385

    Returns: 8

  43. 157

    40035

    Returns: 8

  44. 159

    40545

    Returns: 8

  45. 80

    40880

    Returns: 9

  46. 82

    41902

    Returns: 9

  47. 120

    61320

    Returns: 9

  48. 155

    79205

    Returns: 9

  49. 158

    80738

    Returns: 9

  50. 83

    84909

    Returns: 10

  51. 91

    93093

    Returns: 10

  52. 93

    95139

    Returns: 10

  53. 108

    110484

    Returns: 10

  54. 110

    112530

    Returns: 10


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: