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 - kcal
Problem Statement
We have a beverage that contains $A$ kilocalories per 100 milliliters. How many kilocalories does $B$ milliliters of this beverage contain?
$0\le A, B\le 1000$
Input Format
$A~B$
Output Format
Output the number of kilocalories in $B$ milliliters. Maximum allowable floating-point precision error is $10^{-6}$.
Samples
$A$ | $B$ | Output |
---|---|---|
$45$ | $200$ | $90$ |
$37$ | $450$ | $166.5$ |
$0$ | $1000$ | $0$ |
$50$ | $0$ | $0$ |
Analysis
The answer is simply $\frac{AB}{100}$.
Code
|
|
B - Permutation Check
Problem Statement
Given a sequence $A=(A_1,A_2,\dots,A_N)$ of length $N$, determine whether $A$ is a permutation of $(1, 2, \dots, N)$.
$1\le A_i\le N\le 10^3$
Input Format
$N$
$A_1~A_2~\dots~A_N$
Output Format
Print Yes
if $A$ is a permutation of $(1, 2, \dots, N)$, otherwise print No
.
Samples
Sample Input 1
|
|
Sample Output 1
|
|
$(3,1,2,4,5)$ is a permutation of $(1,2,3,4,5)$, so output Yes
.
Sample Input 2
|
|
Sample Output 2
|
|
$(3,1,4,1,5,2)$ is not a permutation of $(1,2,3,4,5,6)$, so output No
.
Sample Input 3
|
|
Sample Output 3
|
|
Sample Input 4
|
|
Sample Output 4
|
|
Analysis
Since $1\le A_i\le N$, $A$ is a permutation if and only if all numbers from $1$ to $N$ appear exactly once. We can track occurrences using an array with $\mathcal O(n)$ time complexity.
Code
|
|
C - POW
Problem Statement
Given integers $A$, $B$, and $C$, determine whether $A^C$ is less than, greater than, or equal to $B^C$.
$-10^9\le A,B\le 10^9$
$1\le C\le 10^9$
Input Format
$A~B~C$
Output Format
Output:
<
if $A^C < B^C$,>
if $A^C > B^C$,=
if $A^C = B^C$.
Samples
$A$ | $B$ | $C$ | Output |
---|---|---|---|
$3$ | $2$ | $4$ | > |
$-7$ | $7$ | $2$ | = |
$-8$ | $6$ | $3$ | < |
Analysis
For even $C$, compare absolute values. For odd $C$, compare original values. This simplifies to comparing $|A|$ vs $|B|$ (if $C$ is even) or $A$ vs $B$ (if $C$ is odd).
Code
|
|
D - Kth Excluded
Problem Statement
Given a sorted sequence $A=(A_1,A_2,\dots,A_N)$ of positive integers and $Q$ queries, find the $K_i$-th smallest positive integer not present in $A$.
$1\le N,Q\le 10^5$
$1\le A_1 < A_2 < \dots < A_N\le10^{18}$
$1\le K_i\le 10^{18}$
Input Format
$N~Q$
$A_1~A_2~\dots~A_N$
$K_1$
$K_2$
$\hspace{5pt}\vdots$
$K_Q$
Output Format
Output $Q$ lines, each containing the answer for the corresponding query.
Samples
Sample Input 1
|
|
Sample Output 1
|
|
The missing positive integers are $1,2,4,8,9,10,11,\dots$. The 2nd, 5th, and 3rd smallest are $2$, $9$, $4$.
Sample Input 2
|
|
Sample Output 2
|
|
Analysis
Precompute how many elements in $A$ are less than each possible $k$, then use binary search to find the position where $k$ falls. Time complexity: $\mathcal O(Q \log N)$.
Code
|
|
E - White and Black Balls
Problem Statement
Count the number of valid arrangements of $N$ white and $M$ black balls such that for every prefix of length $i$, the number of white balls $w_i$ and black balls $b_i$ satisfy $w_i \le b_i + K$. Modulo $10^9+7$.
$0\le N,M\le10^6$
$1\le N+M$
$0\le K\le N$
Input Format
$N~M~K$
Output Format
Output the count modulo $10^9+7$.
Samples
$N$ | $M$ | $K$ | Output |
---|---|---|---|
$2$ | $3$ | $1$ | $9$ |
$1$ | $0$ | $0$ | $0$ |
$1000000$ | $1000000$ | $1000000$ | $192151600$ |
Analysis
The valid count equals the Catalan-like number $\binom{N+M}{N} - \binom{N+M}{M+K+1}$ when $N \le M + K$, otherwise $0$. This uses combinatorial subtraction for paths crossing a boundary.
Code
|
|