Problem Statement
John couldn't handle long strings so he came up with the idea of MicroStrings.
You are given two positive
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
12
5
Returns: "1272"
This is the example from the problem statement.
3
2
Returns: "31"
31
40
Returns: "31"
30
6
Returns: "3024181260"
The number 0 is also non-negative. When we convert it into a string, we get the string "0".
1
1
Returns: "10"
1
2
Returns: "1"
2
1
Returns: "210"
2
2
Returns: "20"
2
3
Returns: "2"
3
1
Returns: "3210"
3
3
Returns: "30"
3
4
Returns: "3"
4
1
Returns: "43210"
4
2
Returns: "420"
4
3
Returns: "41"
4
4
Returns: "40"
4
5
Returns: "4"
5
1
Returns: "543210"
10
1
Returns: "109876543210"
10
2
Returns: "1086420"
10
3
Returns: "10741"
10
4
Returns: "1062"
10
5
Returns: "1050"
10
6
Returns: "104"
10
7
Returns: "103"
10
8
Returns: "102"
10
9
Returns: "101"
10
10
Returns: "100"
10
11
Returns: "10"
99
8
Returns: "9991837567595143352719113"
99
9
Returns: "9990817263544536271890"
99
10
Returns: "9989796959493929199"
99
11
Returns: "9988776655443322110"
99
12
Returns: "99877563513927153"
99
1
Returns: "9998979695949392919089888786858483828180797877767574737271706968676665646362616059585756555453525150494847464544434241403938373635343332313029282726252423222120191817161514131211109876543210"
100
9
Returns: "100918273645546372819101"
100
10
Returns: "1009080706050403020100"
100
11
Returns: "10089786756453423121"
100
19
Returns: "100816243245"
100
20
Returns: "100806040200"
100
21
Returns: "10079583716"
100
24
Returns: "1007652284"
100
25
Returns: "1007550250"
100
26
Returns: "100744822"
100
49
Returns: "100512"
100
50
Returns: "100500"
100
51
Returns: "10049"
100
100
Returns: "1000"
200
1
Returns: "2001991981971961951941931921911901891881871861851841831821811801791781771761751741731721711701691681671661651641631621611601591581571561551541531521511501491481471461451441431421411401391381371361351341331321311301291281271261251241231221211201191181171161151141131121111101091081071061051041031021011009998979695949392919089888786858483828180797877767574737271706968676665646362616059585756555453525150494847464544434241403938373635343332313029282726252423222120191817161514131211109876543210"
200
2
Returns: "20019819619419219018818618418218017817617417217016816616416216015815615415215014814614414214013813613413213012812612412212011811611411211010810610410210098969492908886848280787674727068666462605856545250484644424038363432302826242220181614121086420"
200
3
Returns: "200197194191188185182179176173170167164161158155152149146143140137134131128125122119116113110107104101989592898683807774716865625956535047444138353229262320171411852"
200
99
Returns: "2001012"
200
100
Returns: "2001000"
200
101
Returns: "20099"
200
199
Returns: "2001"
200
200
Returns: "2000"
1
100
Returns: "1"
20
10
Returns: "20100"
12
30
Returns: "12"
50
1
Returns: "50494847464544434241403938373635343332313029282726252423222120191817161514131211109876543210"
5
5
Returns: "50"
5
2
Returns: "531"
6
6
Returns: "60"