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 - αlphabet
Problem Summary
Input an English letter $a$ and determine whether it is uppercase or lowercase.
Input Format
$a$
Output Format
If $a$ is lowercase, output a
;
If $a$ is uppercase, output A
.
Sample Input 1
|
|
Sample Output 1
|
|
Since B
is uppercase, output A
.
Sample Input 2
|
|
Sample Output 2
|
|
Since a
is lowercase, output a
.
Code
|
|
B - Mix Juice
Problem Summary
Given an array $p_1, p_2, p_3, ..., p_N$ of length $N$, select $K$ elements such that their sum is minimized.
$1\le K\le N\le 1000$
$1\le p_i\le 1000$ ($1\le i\le N$)
Input Format
$N K$
$p_1~p_2~p_3~\dots~p_N$
Output Format
One line containing the minimal sum.
Sample Input 1
|
|
The minimal sum is $50+80+80=210$.
Sample Output 1
|
|
Since B
is uppercase, output A
.
Sample Input 2
|
|
Sample Output 2
|
|
Only one element exists, so the minimal sum is $1000$. (Note added by author)
Code
To minimize the sum, select the $K$ smallest elements in the array. Use the sort()
function from <algorithm>
to sort the array in ascending order, then sum the first $K$ elements.
|
|
C - One Quadrillion and One Dalmatians
Problem Summary
There are $1000000000000001$ ($10^{15}+1$) dogs named as:
a
, b
, .., z
, aa
, ab
, .., az
, ba
, bb
, .., bz
, .., za
, zb
, .., zz
, aaa
, aab
, .., aaz
, aba
, abb
, .., abz
, …, zzz
, aaaa
, …
Question: What is the name of the $N$-th dog?
$1\le N\le 10^{15}+1$
Input Format
$N$
Output Format
One line containing the name of the $N$-th dog.
Samples
Multiple samples are consolidated into a table for brevity:
Input | Output |
---|---|
2 | b |
27 | aa |
123456789 | jjddja |
Code
This is equivalent to converting a decimal number to a base-26 representation:
|
|
D - Replacing
Problem Summary
Given an array $A_1, A_2, \dots, A_N$, perform $Q$ operations:
- In the $i$-th operation, replace all occurrences of $B_i$ with $C_i$.
- Output the sum of all elements in $A$ after each operation (denoted as $S_i$).
$1\le N, Q, A_i, B_i, C_i\le 10^5$ ($1\le i\le N$)
$B_i\ne C_i$
Input Format
$N$
$A_1~A_2~...~A_N$
$Q$
$B_1~C_1$
$B_2~C_2$
$:$
$B_Q~C_Q$
Output Format
$S_1$
$S_2$
$:$
$S_N$
Sample Input 1
|
|
Sample Output 1
|
|
Step | Array $A$ |
---|---|
Initial | $\{1, 2, 3, 4\}$ |
$i=1$ | $\{2, 2, 3, 4\}$ |
$i=2$ | $\{2, 2, 4, 4\}$ |
$i=3$ | $\{4, 4, 4, 4\}$ |
Sample Input 2
|
|
Note: $B_i$ may not exist in the array.
Sample Output 2
|
|
Sample Input 3
|
|
Sample Output 3
|
|
Code
Use an array to track the frequency of each value in $A$. Also maintain the total sum of the array.
|
|