#P15294. [ROI 2012 Day 1] password 密码
[ROI 2012 Day 1] password 密码
Background
Translation source: loj #5455. 「ROI 2012 Day 1」password.
Problem Description
An Olympiad contestant is studying a program used to encrypt login passwords for a system. After running, the program outputs two natural numbers. The second number is obtained from the first number by replacing some non-empty contiguous block of digits with the sum of those digits. It is known that the password is exactly the block of digits in the first number that was replaced by the corresponding sum in the second number.
You need to write a program that, given these two numbers, determines the starting and ending positions of the block of digits that forms the password.
Input Format
The input file contains two lines. The first line is the first number, containing no more than digits. The second line is the second number. It is guaranteed that neither number has leading zeros.
Output Format
The output file should contain two integers separated by a space, representing the starting position and ending position of the replaced block of digits in the first number. If there are multiple solutions, you may output any one of them. It is guaranteed that at least one solution exists.
2148
213
2 4
8
8
1 1
1223
1223
4 4
10002
1002
3 4
Hint
In the first sample, the digit block is replaced by (that is, ).
The detailed additional constraints and scores for the subtasks are shown in the table below:
| Subtask | Score | Additional Constraints |
|---|---|---|
| The first number is less than . | ||
| The first number is less than . | ||
| The first number is less than . |
Translated by ChatGPT 5