#P1732D1. Balance (Easy version)
Balance (Easy version)
No submission language available for this problem.
Description
This is the easy version of the problem. The only difference is that in this version there are no "remove" queries.
Initially you have a set containing one element — . You need to handle queries of the following types:
- + — add the integer to the set. It is guaranteed that this integer is not contained in the set;
- ? — find the of the set.
In our problem, we define the of a set of integers as the smallest non-negative integer that is divisible by and which is not contained in the set.
The first line contains an integer () — the number of queries.
The following lines describe the queries.
An addition query of integer is given in the format + (). It is guaranteed that was not contained in the set.
A search query of is given in the format ? ().
It is guaranteed that there will be at least one query of type ?.
For each query of type ? output a single integer — the of the set.
Input
The first line contains an integer () — the number of queries.
The following lines describe the queries.
An addition query of integer is given in the format + (). It is guaranteed that was not contained in the set.
A search query of is given in the format ? ().
It is guaranteed that there will be at least one query of type ?.
Output
For each query of type ? output a single integer — the of the set.
Note
In the first example:
After the first and second queries, the set will contain elements . The smallest non-negative number that is divisible by and is not contained in the set is .
After the fourth query, the set will contain the elements . The smallest non-negative number that is divisible by and is not contained in the set is .
In the second example:
- Initially, the set contains only the element .
- After adding an integer the set contains elements .
- of the set is .
- After adding an integer the set contains elements .
- of the set is .
- After adding an integer the set contains elements .
- of the set is .