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 - Health M Death
Problem Statement
A magician is fighting a monster with HP $H$.
The magician can defeat the monster when its HP is a multiple of $M$.
Can the magician defeat the monster?
$1\le M,H\le 1000$
Input Format
$M~H$
Output Format
Print Yes if the magician can defeat the monster; otherwise, print No.
Sample Cases
| $M$ | $H$ | Output |
|---|---|---|
| $10$ | $120$ | Yes |
| $10$ | $125$ | No |
Analysis
Check if $H$ is a multiple of $M$.
Code
|
|
B - Many Oranges
Problem Statement
We have many oranges. Each orange weighs between $A$ and $B$ grams (inclusive, possibly non-integer).
The total weight of these oranges is exactly $W$ kilograms.
Find the minimum and maximum possible number of oranges.
$1\le A\le B\le 1000$
$1\le W\le 1000$
Input Format
$A~B~W$
Output Format
Print the minimum and maximum number of oranges separated by a space. If the scenario is impossible, print UNSATISFIABLE.
Sample Cases
| $A$ | $B$ | $W$ | Output |
|---|---|---|---|
| $100$ | $200$ | $2$ | $10 20$ |
| $120$ | $150$ | $2$ | $14 16$ |
| $300$ | $333$ | $1$ | UNSATISFIABLE |
Analysis
For the minimum number, assume each orange has maximum weight $B$: $min = \lceil \frac{W \times 1000}{B} \rceil$.
For the maximum number, assume each orange has minimum weight $A$: $max = \lfloor \frac{W \times 1000}{A} \rfloor$.
If $min > max$, output UNSATISFIABLE; otherwise, output $min$ and $max$.
Code
|
|
C - Comma
Problem Statement
When writing an integer, we place a comma every three digits from the right. For example, $1234567$ becomes 1,234,567, and $777$ remains 777.
How many commas are needed when writing all integers from $1$ to $N$ inclusive?
$1\le N\le 10^{15}$
Input Format
$N$
Output Format
Print the total number of commas.
Sample Cases
| $N$ | Output |
|---|---|
| $1010$ | $11$ |
| $27182818284590$ | $107730272137364$ |
Analysis
Count commas by digit positions. For each power of 1000 starting from $10^3$, add the count of numbers greater than or equal to that power.
Code
|
|
D - Shipping Center
Problem Statement
We have $N$ packages (1 to $N$) and $M$ boxes (1 to $M$).
Package $i$ has size $W_i$ and value $V_i$.
Box $i$ can hold exactly one package with size $\leq X_i$.
For $Q$ queries, each specifying $L$ and $R$, determine the maximum total value when boxes $L$ to $R$ are unavailable.
$1\le N,M,Q\le 50$
$1\le W_i,V_i,X_i\le 10^6$
$1\le L\le R\le M$
Input Format
$N~M~Q$
$W_1~V_1$
$\vdots$
$W_N~V_N$
$X_1~\dots~X_M$
$L_1~R_1$
$\vdots$
$L_Q~R_Q$
Output Format
Print $Q$ lines containing answers for each query.
Sample Input
|
|
Sample Output
|
|
Analysis
Sort boxes by size. For each query, greedily assign the most valuable package that fits each available box.
Code
|
|
E - Lucky 7 Battle
Problem Statement
Given a digit string $S$ of length $N$ and a string $X$ of A and T of length $N$, Takahashi and Aoki play a game:
- On turn $i$, if $X_i$ is
A, Aoki chooses to append $S_i$ or0to string $T$; otherwise, Takahashi chooses. - After $N$ turns, if $T$ represents a number divisible by 7, Takahashi wins; else, Aoki wins.
Determine the winner when both play optimally.
$1\le N\le 10^5$
Input Format
$N$
$S$
$X$
Output Format
Print Takahashi or Aoki.
Sample Cases
See AtCoder.
Analysis
Use memoization to track the winner for each (turn, current modulo 7). The current player wins if any choice leads to their victory.
Code
|
|