MicroStrings
SRM 614 · 2013-12-22 · by Cricicle
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.
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.
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"
Submissions are judged against all 63 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class MicroStrings with a public method string makeMicroString(int A, int D) · 63 test cases · 2 s / 256 MB per case