The Sum of Good Numbers solution codeforces
Let’s call a positive integer good if there is no digit 0 in its decimal representation.
For an array of a good numbers , one found out that the sum of some two neighboring elements is equal to (i.e. for some ). had turned out to be a good number as well.
Then the elements of the arraywere written out one after another without separators into one string . For example, if , then .
You are given a stringand a number . Your task is to determine the positions in the string that correspond to the adjacent elements of the array that have sum . If there are several possible answers, you can print any of them.
The first line contains the string( ).
The second line contains an integer( ).
An additional constraint on the input: the answer always exists, i.e you can always select two adjacent substrings of the stringso that if you convert these substrings to integers, their sum is equal to .
In the first line, print two integers, , meaning that the first term of the sum ( ) is in the string from position to position .
In the second line, print two integers, , meaning that the second term of the sum ( ) is in the string from position to position .
1 2 3 3
2 3 4 6
1 1 2 2
2 7 8 13
In the first exampleand , .
In the second exampleand , .
In the third exampleand , .
In the fourth exampleand , .