Statistics

Problem Statement for "HardIneq"

Problem Statement

A very famous algorithms text presents its readers with a seemingly simple math problem in its opening chapter:
Find the smallest positive integer value of n such that a*(n^k) < k^n, where a and k are given integral values and ^ denotes exponentiation.
Solving this problem algebraically involves using the overly complicated Lambert W function. Instead you are to solve the problem by creating a class HardIneq with a method biggestVal which, given a and k, returns the smallest positive integer value of n such that a*(n^k) < k^n.

Definition

Class:
HardIneq
Method:
biggestVal
Parameters:
int, int
Returns:
int
Method signature:
int biggestVal(int a, int k)
(be sure your method is public)

Notes

  • Remember that log(x^y) = y * log(x) and that log(x*y) = log(x) + log(y)

Constraints

  • a will be between 1 and 10000, inclusive
  • k will be between 2 and 1000, inclusive

Examples

  1. 10

    5

    Returns: 8

    if n = 1, we have a*(n^k) = 10*(1^5) = 10, and k^n = 5^1 = 5. 10 is not less than 5. n=2: 10*2^5 is not less than 5^2 n=2: 10*3^5 is not less than 5^3 and so on. Not until we get to n = 8, and have 10*8^5 = 327680, and 5^8 = 390625 is the inequality satisfied.

  2. 1

    2

    Returns: 1

    1*(1^2) is less than 2^1, so we return 1.

  3. 2

    20

    Returns: 1

  4. 2000

    200

    Returns: 202

  5. 1000

    100

    Returns: 102

  6. 503

    33

    Returns: 36

  7. 31

    23

    Returns: 25

  8. 100

    99

    Returns: 101

  9. 657

    12

    Returns: 17

  10. 99

    100

    Returns: 1

  11. 861

    2

    Returns: 19

  12. 1634

    242

    Returns: 244

  13. 3147

    434

    Returns: 436

  14. 463

    777

    Returns: 1

  15. 4210

    191

    Returns: 193

  16. 1387

    7

    Returns: 13

  17. 2740

    73

    Returns: 76

  18. 6248

    797

    Returns: 799

  19. 4913

    95

    Returns: 98

  20. 4046

    448

    Returns: 450

  21. 265

    651

    Returns: 1

  22. 6103

    582

    Returns: 584

  23. 2208

    649

    Returns: 651

  24. 6063

    918

    Returns: 920

  25. 6661

    714

    Returns: 716

  26. 8667

    459

    Returns: 461

  27. 5040

    509

    Returns: 511

  28. 1562

    541

    Returns: 543

  29. 828

    999

    Returns: 1

  30. 2541

    112

    Returns: 115

  31. 4765

    807

    Returns: 809

  32. 561

    517

    Returns: 519

  33. 2245

    613

    Returns: 615

  34. 2626

    84

    Returns: 87

  35. 7991

    962

    Returns: 964

  36. 230

    791

    Returns: 1

  37. 7248

    708

    Returns: 710

  38. 8402

    344

    Returns: 346

  39. 9813

    755

    Returns: 757

  40. 7625

    58

    Returns: 61

  41. 3061

    752

    Returns: 754

  42. 3877

    52

    Returns: 55

  43. 2789

    851

    Returns: 853

  44. 4907

    379

    Returns: 381

  45. 6184

    678

    Returns: 680

  46. 1439

    904

    Returns: 906

  47. 9515

    234

    Returns: 237

  48. 505

    912

    Returns: 1

  49. 4238

    506

    Returns: 508

  50. 4320

    680

    Returns: 682

  51. 9142

    214

    Returns: 217

  52. 2200

    492

    Returns: 494

  53. 2866

    237

    Returns: 239

  54. 4924

    866

    Returns: 868

  55. 688

    975

    Returns: 1

  56. 613

    91

    Returns: 93

  57. 1801

    94

    Returns: 97

  58. 8722

    508

    Returns: 510

  59. 8507

    841

    Returns: 843

  60. 4072

    390

    Returns: 392

  61. 6690

    424

    Returns: 426

  62. 27

    3

    Returns: 10

    Note that 27*9^3 is equal to 3^9.

  63. 729

    6

    Returns: 13

  64. 10000

    1000

    Returns: 1002

  65. 2000

    200

    Returns: 202

  66. 27

    3

    Returns: 10

  67. 9999

    1000

    Returns: 1002


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: