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 - Very Very Primitive Game
Problem Statement
Takahashi and Aoki are playing a game. The rules are as follows:
- Initially, Takahashi and Aoki have $A$ and $B$ candies, respectively.
- They take turns eating one candy. The first player unable to eat loses. If $C=0$, Takahashi goes first; if $C=1$, Aoki goes first.
Output the winner’s name.
$0\le A,B\le 100$
$C \in \{0,1\}$
Input Format
$A~B~C$
Output Format
Print the winner.
Sample Cases
A | B | C | Output |
---|---|---|---|
2 | 1 | 0 | Takahashi |
2 | 2 | 0 | Aoki |
2 | 2 | 1 | Takahashi |
Analysis
If Aoki starts first ($C=1$), he wins when $B > A$. For Takahashi starting first ($C=0$), increment $B$ by 1 to simulate Aoki’s first move scenario, then check if $B > A$.
Code
|
|
B - Magic 3
Problem Statement
A magician battles a monster. He can use $N$ spells. The $i$-th spell has cooldown $X_i$ seconds and deals $Y_i$ damage. The monster is immune to spells with cooldown $\geq S$ or damage $\leq D$. Can the magician damage the monster?
$1\le N\le 100$
$1\le X_i, Y_i\le 10^9$
$1\le S, D\le 10^9$
Input Format
$N~S~D$
$X_1~Y_1$
$X_2~Y_2$
$\vdots$
$X_N~Y_N$
Output Format
Print Yes
if possible, otherwise No
.
Sample Cases
Sample Input 1
|
|
Sample Output 1
|
|
With $S=D=9$:
Spell No. | Cooldown | Damage | Can Damage Monster? |
---|---|---|---|
1 | 5 sec β | 5 β | β |
2 | 15 sec β | 5 β | β |
3 | 5 sec β | 15 β | β |
4 | 15 sec β | 15 β | β |
Sample Input 2
|
|
Sample Output 2
|
|
Sample Input 3
|
|
Sample Output 3
|
|
Only the 7th spell works.
Analysis
For each spell, check if $X_i < S$ and $Y_i > D$ hold. Output Yes
if any spell satisfies both conditions.
Code
|
|
C - Bowls and Dishes
Problem Statement
There are $N$ dishes numbered $1,2,\dots,N$ and $M$ conditions. Condition $i$ is satisfied if both dishes $A_i$ and $B_i$ contain at least one ball. $K$ people each place a ball in dish $C_i$ or $D_i$. Find the maximum number of satisfied conditions.
$2\le N\le 100$
$1\le M\le 100$
$1\le A_i < B_i\le N$
$1\le K\le 16$
$1\le C_i < D_i\le N$
Input Format
$N~M$
$A_1~B_1$
$\vdots$
$A_M~B_M$
$K$
$C_1~D_1$
$\vdots$
$C_K~D_K$
Output Format
Print the maximum count.
Sample Cases
Sample Input 1
|
|
Sample Output 1
|
|
Choosing dishes 1, 3, 2 satisfies conditions 1 and 2.
Sample Input 2
|
|
Sample Output 2
|
|
Choosing dishes 3, 1, 2, 4 satisfies all conditions.
Sample Input 3
|
|
Sample Output 3
|
|
Analysis
Enumerate all $2^K$ choices using bitmasking. For each combination, track which dishes have balls and count satisfied conditions. Time complexity is $\mathcal O(M2^K)$.
Code
|
|
D - Staircase Sequences
Problem Statement
Count the number of arithmetic sequences with sum $N$ and common difference 1 (allowing negative terms).
$1\le N\le 10^{12}$
Input Format
$N$
Output Format
Print the count.
Sample Cases
N | Output |
---|---|
12 | 4 |
1 | 2 |
63761198400 | 1920 |
Analysis
$$\frac {(a+b)(b-a+1)} 2 = N$$$$(a+b)(b-a+1) = 2N$$
We count pairs of factors of $2N$ with different parity (one even, one odd). Multiply the result by 2 to account for negative sequences. Time complexity is $\mathcal O(\sqrt N)$.
Code
|
|