-->
当前位置:首页 > 题库

PROGRAMMING:Well, if it was you, it would be the problem

Luz5年前 (2021-05-10)题库358
Although Qianqiao has no dream, it can protect other people's dream. Now Wang Xiaoming has a dream, which is to maintain a sequence. At the beginning, the sequence is empty. The following two operations are provided: Q operation syntax: Q L, function: query the largest number in the L numbers at the end of the current sequence, and output the value of this number. Limit: l does not exceed the length of the current sequence. A operation syntax: a n, function: add n to t, where t is the answer of the latest query operation (if the query operation has not been performed, then t = 0), and modulus the result to a fixed constant mod, and insert the result to the end of the sequence. Restriction: n is a non negative integer and is in the range of long integer.
###Input format:
The first line contains two integers, m and D, where m is the number of operations (m < = 200000), mod is as described above, and mod is in the Longint. Next, M-line, query operation or insert operation.
###Output format:
For each query operation, output one line. The row has only one number, which is the maximum number of the last l numbers in the sequence.
###Input example:
Here is a set of inputs. For example:
```in
5 100
A 96
Q 1
A 97
Q 1
Q 2
```
###Output example:
The corresponding output is given here. For example:
```out
ninety-six
ninety-three
ninety-six
```







answer:If there is no answer, please comment