Statistics

Problem Statement for "DepositProfit"

Problem Statement

You've deposited amount dollars into a bank account. The interest rate is annualInterest percent per year, and it is compounded monthly. This means that at the end of each month, the total balance increases by annualInterest/12 percent, and after that the balance is rounded down to the integer number of cents. Return the minimum number of months required to obtain at least profit dollars in profit.

Definition

Class:
DepositProfit
Method:
depositTerm
Parameters:
int, int, int
Returns:
int
Method signature:
int depositTerm(int amount, int annualInterest, int profit)
(be sure your method is public)

Notes

  • The monthly interest is calculated as (current deposit amount) * (annual interest rate in percent) / (100*12).

Constraints

  • amount will be between 10 and 10000, inclusive.
  • annualInterest will be between 4 and 24, inclusive.
  • profit will be between 1 and amount, inclusive.

Examples

  1. 1000

    12

    20

    Returns: 2

    The monthly interest rate is 1%. At the end of the first month, the interest added is 1000*0.01 = 10, for a new total balance of 1010. At the end of the second month, the interest added is 1010*0.01 = 10.10, for a total balance of 1020.10. At this point, the profit is 20.10, which is greater than 20.

  2. 10

    4

    10

    Returns: 236

  3. 5000

    24

    4000

    Returns: 30

  4. 1000

    6

    5

    Returns: 1

    The monthly interest rate is 0.5%. At the end of the first month, the interest added is equal to the profit wanted.

  5. 3411

    14

    1536

    Returns: 33

  6. 5509

    13

    3857

    Returns: 50

  7. 5409

    7

    1891

    Returns: 52

  8. 4785

    12

    706

    Returns: 14

  9. 4059

    19

    2828

    Returns: 34

  10. 3592

    8

    3483

    Returns: 103

  11. 9302

    12

    8476

    Returns: 66

  12. 8275

    24

    2650

    Returns: 15

  13. 610

    23

    383

    Returns: 26

  14. 6181

    19

    3806

    Returns: 31

  15. 6452

    23

    4451

    Returns: 28

  16. 583

    16

    30

    Returns: 4

  17. 1935

    20

    1009

    Returns: 26

  18. 1201

    12

    357

    Returns: 27

  19. 282

    10

    15

    Returns: 7

  20. 1109

    10

    799

    Returns: 66

  21. 2421

    19

    1574

    Returns: 32

  22. 6721

    4

    4060

    Returns: 143

  23. 8184

    21

    1870

    Returns: 12

  24. 2564

    17

    1281

    Returns: 29

  25. 6882

    23

    5290

    Returns: 31

  26. 8006

    14

    6183

    Returns: 50

  27. 672

    16

    652

    Returns: 52

  28. 1217

    23

    376

    Returns: 15

  29. 889

    18

    731

    Returns: 41

  30. 1015

    24

    14

    Returns: 1

  31. 1950

    8

    887

    Returns: 57

  32. 4273

    19

    2950

    Returns: 34

  33. 1104

    7

    1090

    Returns: 119

  34. 7569

    23

    7086

    Returns: 35

  35. 5753

    21

    960

    Returns: 9

  36. 5176

    14

    3659

    Returns: 47

  37. 9612

    6

    3914

    Returns: 69

  38. 2252

    6

    845

    Returns: 64

  39. 330

    23

    78

    Returns: 12

  40. 1562

    12

    585

    Returns: 32

  41. 6651

    13

    2899

    Returns: 34

  42. 9680

    6

    7420

    Returns: 115

  43. 716

    21

    445

    Returns: 28

  44. 4514

    18

    2198

    Returns: 27

  45. 5923

    16

    1916

    Returns: 22

  46. 4327

    9

    4220

    Returns: 92

  47. 7429

    10

    1304

    Returns: 20

  48. 2144

    24

    2105

    Returns: 35

  49. 9017

    13

    4937

    Returns: 41

  50. 4324

    7

    2694

    Returns: 84

  51. 3845

    15

    281

    Returns: 6

  52. 1256

    12

    706

    Returns: 45

  53. 7605

    16

    705

    Returns: 7

  54. 5427

    21

    3322

    Returns: 28

  55. 6653

    15

    1861

    Returns: 20

  56. 5000

    18

    2369

    Returns: 27

  57. 3765

    8

    3419

    Returns: 98

  58. 1490

    17

    1366

    Returns: 47

  59. 3794

    4

    1038

    Returns: 73

  60. 745

    13

    362

    Returns: 37

  61. 495

    16

    495

    Returns: 53

  62. 5936

    15

    4566

    Returns: 46

  63. 4722

    18

    596

    Returns: 8

  64. 10000

    4

    10000

    Returns: 209

  65. 10000

    24

    404

    Returns: 2

  66. 400

    9

    3

    Returns: 1

  67. 10000

    12

    201

    Returns: 2

  68. 36

    4

    32

    Returns: 197

  69. 4438

    6

    4350

    Returns: 137

  70. 270

    4

    120

    Returns: 111

  71. 9459

    6

    7579

    Returns: 118

  72. 18

    4

    8

    Returns: 118

  73. 8238

    12

    5176

    Returns: 49

  74. 10

    4

    1

    Returns: 34

    At the end of the first month, the interest added is approximately 3.33 cents. At the end of the 34-th month, the interest added is approximately 3.67 cents. Both these interests are rounded down to 3 cents.

  75. 100

    12

    1

    Returns: 1

  76. 1000

    12

    10

    Returns: 1

  77. 9876

    23

    9875

    Returns: 37


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: