#abc298d. D - Writing a Numeral
D - Writing a Numeral
Score : points
问题描述
我们有一个字符串 。初始时, 1
。
按照以下格式顺序处理 个查询操作:
1 x
:在 的末尾追加一个数字 。2
:删除 开头的数字。3
:计算以 表示的十进制数对 取模的结果,并打印该数值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have a string . Initially, 1
.
Process queries in the following formats in order.
1 x
: Append a digit at the end of .2
: Delete the digit at the beginning of .3
: Print the number represented by in decimal, modulo .
Constraints
- For each query in the first format, .
- A query in the second format is given only if has a length of or greater.
- There is at least one query in the third format.
Input
The input is given from Standard Input in the following format:
Here, denotes the -th query, which is in one of the following formats:
Output
Print lines, where is the number of queries in the third format. The -th line should correspond to the -th query in the third format.
Sample Input 1
3
3
1 2
3
Sample Output 1
1
12
In the first query, is 1
, so you should print modulo , that is, .
In the second query, becomes 12
.
In the third query, is 12
, so you should print modulo , that is, .
Sample Input 2
3
1 5
2
3
Sample Output 2
5
Sample Input 3
11
1 9
1 9
1 8
1 2
1 4
1 4
1 3
1 5
1 3
2
3
Sample Output 3
0
Be sure to print numbers modulo .
update @ 2024/3/10 12:22:06