Statistics

Problem Statement for "DivToZero"

Problem Statement

You are given an integer num from which you should replace the last two digits such that the resulting number is divisible by factor and is also the smallest possible number. Return the two replacement digits as a String.

For instance:

if num = 275, and factor = 5, you would return "00" because 200 is divisible by 5.
if num = 1021, and factor = 11, you would return "01" because 1001 is divisible by 11.
if num = 70000, and factor = 17, you would return "06" because 70006 is divisible by 17.

Definition

Class:
DivToZero
Method:
lastTwo
Parameters:
int, int
Returns:
String
Method signature:
String lastTwo(int num, int factor)
(be sure your method is public)

Constraints

  • factor must be between 1 and 100, inclusive.
  • num must be between 100 and 2,000,000,000, inclusive.

Examples

  1. 2000000000

    100

    Returns: "00"

  2. 1000

    3

    Returns: "02"

  3. 23442

    75

    Returns: "00"

  4. 428392

    17

    Returns: "15"

  5. 32442

    99

    Returns: "72"

  6. 100

    100

    Returns: "00"

  7. 100

    99

    Returns: "98"

  8. 1000

    99

    Returns: "89"

  9. 374293384

    43

    Returns: "28"

  10. 743295

    1

    Returns: "00"

  11. 77329438

    13

    Returns: "08"

  12. 1999999999

    19

    Returns: "07"

  13. 53626

    77

    Returns: "69"

  14. 1364976

    11

    Returns: "02"

  15. 456

    18

    Returns: "14"

  16. 7347364

    83

    Returns: "26"

  17. 29837463

    2

    Returns: "00"

  18. 2000000000

    61

    Returns: "46"

  19. 7838392

    87

    Returns: "52"

  20. 72747322

    97

    Returns: "81"

  21. 783376226

    56

    Returns: "16"

  22. 8192

    16

    Returns: "12"

  23. 65536

    64

    Returns: "36"

  24. 84010

    35

    Returns: "00"

  25. 90210

    15

    Returns: "10"

  26. 80087355

    69

    Returns: "34"

  27. 38729292

    80

    Returns: "00"

  28. 1111111111

    12

    Returns: "04"

  29. 999999999

    33

    Returns: "24"

  30. 198

    99

    Returns: "98"

  31. 411

    99

    Returns: "95"

  32. 32768

    24

    Returns: "12"

  33. 565656565

    65

    Returns: "20"

  34. 100

    100

    Returns: "00"

  35. 676

    26

    Returns: "24"

  36. 102

    3

    Returns: "02"

  37. 2000000000

    100

    Returns: "00"

  38. 150

    5

    Returns: "00"

  39. 111

    3

    Returns: "02"

  40. 428392

    17

    Returns: "15"

  41. 100

    99

    Returns: "98"

  42. 217

    7

    Returns: "03"

  43. 112

    7

    Returns: "05"

  44. 141

    3

    Returns: "02"


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: