2082B.md (1812B)
1 Source: https://codeforces.com/problemset/problem/2082/B 2 3 B. Floor or Ceil 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 512 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Ecrade has an integer $x$. There are two kinds of operations. 22 23 1. Replace $x$ with $\left\lfloor \dfrac{x}{2}\right\rfloor$, where $\left\lfloor \dfrac{x}{2}\right\rfloor$ is the greatest integer $\le \dfrac{x}{2}$. 24 2. Replace $x$ with $\left\lceil \dfrac{x}{2}\right\rceil$, where $\left\lceil \dfrac{x}{2}\right\rceil$ is the smallest integer $\ge \dfrac{x}{2}$. 25 26 Ecrade will perform exactly $n$ first operations and $m$ second operations in any order. He wants to know the minimum and the maximum possible value of $x$ after $n+m$ operations. However, it seems a little difficult, so please help him! 27 28 Input 29 30 Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows. 31 32 The only line of each test case contains three integers $x$, $n$, and $m$ ($0 \le x, n, m \le 10^9$). 33 34 Output 35 36 For each test case, print two integers in one line, representing the minimum and the maximum possible value of $x$ after $n + m$ operations. 37 38 Example 39 40 Input 41 42 ``` 43 5 44 45 12 1 2 46 47 12 1 1 48 49 12 0 0 50 51 12 1000000000 1000000000 52 53 706636307 0 3 54 ``` 55 56 Output 57 58 ``` 59 1 2 60 3 3 61 12 12 62 0 0 63 88329539 88329539 64 ``` 65 66 Note 67 68 For simplicity, we call the first operation $\text{OPER 1}$ and the second operation $\text{OPER 2}$. 69 70 In the first test case: 71 72 * If we perform $12 \xrightarrow{\text{OPER 2}} 6 \xrightarrow{\text{OPER 2}} 3 \xrightarrow{\text{OPER 1}} 1$, we can obtain the minimum possible value $1$. 73 * If we perform $12 \xrightarrow{\text{OPER 2}} 6 \xrightarrow{\text{OPER 1}} 3 \xrightarrow{\text{OPER 2}} 2$, we can obtain the maximum possible value $2$.