#P2838. Bottle Operations Arithmetic
Bottle Operations Arithmetic
Bottle Operations Arithmetic
In the mysterious Bottle Kingdom, water is used to represent numbers. Each bottle has a capacity equal to the maximum amount of water it can hold. The king of Bottle Kingdom has decreed several operations on bottles, which are explained below in (\LaTeX) format:
- (I): Create a new bottle whose capacity and current water amount are equal to the given number. Its bottle ID becomes the current maximum ID plus one.
- (F\ s): Fill bottle (s) to its full capacity.
- (E\ s): Empty bottle (s) completely.
- (C\ s): Create a new bottle with capacity (s) (with (0 \le s \le 10^9)) and no water inside. Its bottle ID becomes the current maximum ID plus one.
- (M\ s): Create a new bottle with capacity equal to the current water amount in bottle (s) (initially empty). Its bottle ID becomes the current maximum ID plus one.
- (T\ a\ b): Pour water from bottle (a) to bottle (b) until bottle (a) is empty or bottle (b) is full (with (a \neq b)).
- (O\ s): Output the amount of water in bottle (s).
- (K\ a\ b): Create a new bottle with capacity equal to the product of the capacities of bottle (a) and bottle (b), i.e. (\text{capacity}(a)\times\text{capacity}(b)). Note that this product cannot exceed (10^9). (This operation is expensive and will deduct points, see scoring details.)
However, you do not need to simulate these bottle operations. Instead, the king has provided you with several arithmetic tasks. Your program is given a task number (from 1 to 10) and the corresponding input values. You are to compute and output the result as described below:
- For inputs (a) and (b) (with (0\le a,b\le 10^5)), output (a+b).
- For inputs (a) and (b) (with (0\le a,b\le 10^5)), output (|a-b|).
- For inputs (a) and (b) (with (0\le a,b\le 10^5)), output (\max(a,b)).
- For inputs (a) and (b) (with (1\le a,b\le 1000)), output (\gcd(a,b)).
- For input (a) (with (0\le a\le 10^5)), output its 32‐bit binary representation. The binary digits must be separated by a single space. For example, if (a=5), output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 - For inputs (a) and (b) (with (0\le a,b\le 1000)), output (a\times b).
- For inputs (a) and (b) (with (0\le a,b\le 10^5)), output (a \oplus b) (the bitwise XOR).
- For input (a) (with (1\le a\le 10000)), output (\lfloor a/10\rfloor).
- For inputs (a) and (b) (with (0\le a,b\le 10^5)), output (a\times b \bmod 262144).
- For inputs (a) and (b) (with (1\le a,b\le 1000) and ensuring (a^b\le 10^6)), output (a^b).
Input Format: The input begins with an integer representing the task number (from 1 to 10). This is followed by the necessary integer(s) for that task, separated by spaces.
Output Format: Output a single line containing the result of the specified arithmetic task.
Note: Your submission should output a sequence of operations (in the real story these operations are executed by the bottles). In this simplified version, you only need to compute and print the final result.
inputFormat
The first integer of the input indicates the task number (an integer from 1 to 10). Depending on the task, the following integer(s) are provided:
Task 1,2,3,6,7,9,10: Two integers (a) and (b).
Task 4: Two integers (a) and (b) (with (a,b \ge 1)).
Task 5,8: A single integer (a).
All numbers are separated by spaces or newlines.
outputFormat
Print a single line containing the result of the arithmetic computation corresponding to the task number.
sample
1
3 5
8