#P15294. [ROI 2012 Day 1] password 密码

    ID: 17373 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 显示难度普及− 上传者: 标签>2012Special JudgeROI(俄罗斯)

[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 10510^5 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 148148 is replaced by 1313 (that is, 1+4+8=131 + 4 + 8 = 13).

The detailed additional constraints and scores for the subtasks are shown in the table below:

Subtask Score Additional Constraints
11 3030 The first number is less than 10910^{9}.
22 The first number is less than 10100010^{1000}.
33 4040 The first number is less than 1010000010^{100000}.

Translated by ChatGPT 5