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 - Star
Problem Statement
What is the difference between the next multiple of 100 greater than X and X itself?
$1\le X\le 10^5$
Input Format
$X$
Output Format
Print the answer.
Sample
$X$ | Output |
---|---|
$140$ | $60$ |
$1000$ | $100$ |
Analysis
The next multiple of 100 greater than $X$ is $(\lfloor X/100\rfloor+1)\times 100$. Thus, output $(\lfloor X/100\rfloor+1)\times 100-X$.
Code
|
|
B - uNrEaDaBlE sTrInG
Problem Statement
A string is unreadable if all characters at odd positions (1st, 3rd, 5th, etc., 1-based) are lowercase letters and all even positions are uppercase. Determine if $S$ is unreadable.
$1\le |S|\le 1000$
$S$ consists of uppercase and lowercase letters.
Input Format
$S$
Output Format
Print Yes
if $S$ is unreadable, otherwise No
.
Sample
$S$ | Output |
---|---|
$\text{dIfFiCuLt}$ | Yes |
$\text{eASY}$ | No |
$\text{a}$ | Yes |
Analysis
Check each position according to the rules.
Code
|
|
C - Kaprekar Number
Problem Statement
For natural number $x$, define:
- $g1(x)$: $x$’s digits sorted in descending order
- $g2(x)$: $x$’s digits sorted in ascending order (leading zeros removed)
- $f(x) = g1(x) - g2(x)$
Example: $g1(314)=431$, $g2(3021)=123$, $f(271)=594$.
Given $N$ and $K$, perform $K$ iterations of $N := f(N)$ and output the final $N$.
$0\le N\le 10^9$
$1\le K\le 10^5$
Input Format
$N~K$
Output Format
Print the final $N$.
Sample
$N$ | $K$ | Output |
---|---|---|
$314$ | $2$ | $693$ |
$1000000000$ | $100$ | $0$ |
$6174$ | $100000$ | $6174$ |
Analysis
Use bucket sort to compute $f(n)$ efficiently, achieving $\mathcal O(K)$ total complexity.
Code
|
|
D - Base n
Problem Statement
Given large integer $X$ (not fitting in long long
) and $M$. Let $d$ be the maximum digit in $X$. Count how many $n > d$ satisfy that treating $X$ as a base-$n$ number yields a decimal value β€ $M$.
$X$ has no leading zeros, 1 to 60 digits.
$1\le M\le 10^{18}$
Input Format
$X$
$M$
Output Format
Print the count.
Sample
Samples omitted. Visit AtCoder for details.
Analysis
Valid $n$ range: $d < n \le \text{max possible}$. Use binary search to find the maximum $n$ and subtract $d$.
Code
Key points:
- Binary search boundaries
- Overflow handling during value computation
- Edge case when $X$ is single-digit
Without further ado, let’s dive into the code! β~~~~~~β~~~~~~β
|
|