Translation Notice
This article was machine-translated using DeepSeek-R1.
- Original Version: Authored in Chinese by myself
- Accuracy Advisory: Potential discrepancies may exist between translations
- Precedence: The Chinese text shall prevail in case of ambiguity
- Feedback: Technical suggestions regarding translation quality are welcomed
A - Difference Max
Problem Statement
Given four integers $a$, $b$, $c$, and $d$.
Choose integers $x$ and $y$ such that $a \le x \le b$ and $c \le y \le d$. Find the maximum possible value of $x - y$.
Constraints:
$-100 \le a \le b \le 100$
$-100 \le c \le d \le 100$
Input Format
|
|
Output Format
Print the maximum value of $x - y$.
Sample Cases
$a$ | $b$ | $c$ | $d$ | Output |
---|---|---|---|---|
0 | 10 | 0 | 10 | 10 |
-100 | -100 | 100 | 100 | 200 |
-100 | 100 | -100 | 100 | 200 |
Analysis
To maximize $x - y$, $x$ should be as large as possible ($x = b$) and $y$ as small as possible ($y = c$). Thus, directly output $b - c$.
Code
|
|
B - Round Down
Problem Statement
Given a number $X$, compute $\lfloor X \rfloor$.
Constraints:
$0 \le X \le 10^{100}$
Input Format
|
|
Output Format
Print $\lfloor X \rfloor$.
Sample Cases
X | Output |
---|---|
5.90 | 5 |
0 | 0 |
84939825309432908832902189.9092309409809091329 | 84939825309432908832902189 |
Analysis
Truncate all characters starting from the decimal point. For example: $5\sout{.90}$.
Code
|
|
C - Doubled
Problem Statement
Count how many integers between 1 and $N$ (inclusive) are formed by concatenating two identical positive integers.
Constraints:
$1 \le N < 10^{12}$
Input Format
|
|
Output Format
Print the count.
Sample Cases
N | Output |
---|---|
33 | 3 |
1333 | 13 |
10000000 | 999 |
Analysis
The problem reduces to finding the largest $X$ such that concatenating $X$ twice does not exceed $N$. Use binary search with the right boundary set to $\sqrt{N}$ to avoid overflow.
Code
|
|
D - Hanjo
Problem Statement
Tile an $H \times W$ grid using $A$ $2 \times 1$ dominoes and $B$ $1 \times 1$ squares. Count the number of ways to fully cover the grid.
Constraints:
$1 \le H, W, HW \le 16$
$0 \le A, B$
$2A + B = HW$
Input Format
|
|
Output Format
Print the number of valid tilings.
Sample Cases
H | W | A | B | Output |
---|---|---|---|---|
2 | 2 | 1 | 2 | 4 |
3 | 3 | 4 | 1 | 18 |
4 | 4 | 8 | 0 | 36 |
Analysis
Use backtracking to explore all placements. Track the current position and remaining tiles, placing dominoes horizontally or vertically while avoiding overlaps.
Code
|
|
E - Filters
Problem Statement
Given sequences $A$, $T$, and $X$, compute the composite function $F(x) = f_N(\dots f_2(f_1(x)) \dots)$ for each query $x_i$, where:
- $f_i(x) = x + a_i$ if $t_i = 1$
- $f_i(x) = \max(x, a_i)$ if $t_i = 2$
- $f_i(x) = \min(x, a_i)$ if $t_i = 3$
Constraints:
$1 \le N, Q \le 2 \times 10^5$
$|a_i|, |x_i| \le 10^9$
Input Format
|
|
Output Format
Print $Q$ lines, each containing $F(x_i)$.
Sample Input
|
|
Sample Output
|
|
Analysis
The composite function can be represented as $F(x) = \min(c, \max(b, x + a))$. Track three parameters $a$, $b$, and $c$ through the function chain:
- Additive shifts accumulate in $a$.
- $\max$ operations set lower bounds in $b$.
- $\min$ operations set upper bounds in $c$.
Code
|
|