Statistics

Problem Statement for "MicroStrings"

Problem Statement

John couldn't handle long strings so he came up with the idea of MicroStrings.


You are given two positive ints: A and D. These determine an infinite decreasing arithmetic progression: A, A-D, A-2D, and so on. Clearly, only finitely many elements of such a progression are non-negative.


Each such progression defines one MicroString, as follows: You take all the non-negative elements, convert each of them into a string, and then concatenate those strings (in order).


For example, let A=12 and D=5. For these values we get the arithmetic progression (12, 7, 2, -3, -8, ...). The non-negative elements are 12, 7, and 2. The corresponding strings are "12", "7", and "2". Their concatenation is the following MicroString: "1272".


Given A and D, return the MicroString they define.

Definition

Class:
MicroStrings
Method:
makeMicroString
Parameters:
int, int
Returns:
String
Method signature:
String makeMicroString(int A, int D)
(be sure your method is public)

Notes

  • When converting a number to a string, the string must not have unnecessary leading zeros.

Constraints

  • A will be between 1 and 200, inclusive.
  • D will be between 1 and 200, inclusive.

Examples

  1. 12

    5

    Returns: "1272"

    This is the example from the problem statement.

  2. 3

    2

    Returns: "31"

  3. 31

    40

    Returns: "31"

  4. 30

    6

    Returns: "3024181260"

    The number 0 is also non-negative. When we convert it into a string, we get the string "0".

  5. 1

    1

    Returns: "10"

  6. 1

    2

    Returns: "1"

  7. 2

    1

    Returns: "210"

  8. 2

    2

    Returns: "20"

  9. 2

    3

    Returns: "2"

  10. 3

    1

    Returns: "3210"

  11. 3

    3

    Returns: "30"

  12. 3

    4

    Returns: "3"

  13. 4

    1

    Returns: "43210"

  14. 4

    2

    Returns: "420"

  15. 4

    3

    Returns: "41"

  16. 4

    4

    Returns: "40"

  17. 4

    5

    Returns: "4"

  18. 5

    1

    Returns: "543210"

  19. 10

    1

    Returns: "109876543210"

  20. 10

    2

    Returns: "1086420"

  21. 10

    3

    Returns: "10741"

  22. 10

    4

    Returns: "1062"

  23. 10

    5

    Returns: "1050"

  24. 10

    6

    Returns: "104"

  25. 10

    7

    Returns: "103"

  26. 10

    8

    Returns: "102"

  27. 10

    9

    Returns: "101"

  28. 10

    10

    Returns: "100"

  29. 10

    11

    Returns: "10"

  30. 99

    8

    Returns: "9991837567595143352719113"

  31. 99

    9

    Returns: "9990817263544536271890"

  32. 99

    10

    Returns: "9989796959493929199"

  33. 99

    11

    Returns: "9988776655443322110"

  34. 99

    12

    Returns: "99877563513927153"

  35. 99

    1

    Returns: "9998979695949392919089888786858483828180797877767574737271706968676665646362616059585756555453525150494847464544434241403938373635343332313029282726252423222120191817161514131211109876543210"

  36. 100

    9

    Returns: "100918273645546372819101"

  37. 100

    10

    Returns: "1009080706050403020100"

  38. 100

    11

    Returns: "10089786756453423121"

  39. 100

    19

    Returns: "100816243245"

  40. 100

    20

    Returns: "100806040200"

  41. 100

    21

    Returns: "10079583716"

  42. 100

    24

    Returns: "1007652284"

  43. 100

    25

    Returns: "1007550250"

  44. 100

    26

    Returns: "100744822"

  45. 100

    49

    Returns: "100512"

  46. 100

    50

    Returns: "100500"

  47. 100

    51

    Returns: "10049"

  48. 100

    100

    Returns: "1000"

  49. 200

    1

    Returns: "2001991981971961951941931921911901891881871861851841831821811801791781771761751741731721711701691681671661651641631621611601591581571561551541531521511501491481471461451441431421411401391381371361351341331321311301291281271261251241231221211201191181171161151141131121111101091081071061051041031021011009998979695949392919089888786858483828180797877767574737271706968676665646362616059585756555453525150494847464544434241403938373635343332313029282726252423222120191817161514131211109876543210"

  50. 200

    2

    Returns: "20019819619419219018818618418218017817617417217016816616416216015815615415215014814614414214013813613413213012812612412212011811611411211010810610410210098969492908886848280787674727068666462605856545250484644424038363432302826242220181614121086420"

  51. 200

    3

    Returns: "200197194191188185182179176173170167164161158155152149146143140137134131128125122119116113110107104101989592898683807774716865625956535047444138353229262320171411852"

  52. 200

    99

    Returns: "2001012"

  53. 200

    100

    Returns: "2001000"

  54. 200

    101

    Returns: "20099"

  55. 200

    199

    Returns: "2001"

  56. 200

    200

    Returns: "2000"

  57. 1

    100

    Returns: "1"

  58. 20

    10

    Returns: "20100"

  59. 12

    30

    Returns: "12"

  60. 50

    1

    Returns: "50494847464544434241403938373635343332313029282726252423222120191817161514131211109876543210"

  61. 5

    5

    Returns: "50"

  62. 5

    2

    Returns: "531"

  63. 6

    6

    Returns: "60"


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: