#P8751. Multiple Independent Result Computation Problem
Multiple Independent Result Computation Problem
Multiple Independent Result Computation Problem
This problem consists of five independent subproblems labeled A through E. In each subproblem you are asked to compute a specific integer result. You will be given a single uppercase letter as input, which indicates the subproblem to solve. The answers for each subproblem are described below:
Subproblem A: Remainder
In languages such as C, C++, Java, and Python, the operator %
computes the remainder. Compute the value of 2021 % 20
. Using modulo arithmetic, we can express this as:
\(2021 \bmod 20\)
The answer is an integer.
Subproblem B: Double Factorial
For a positive integer \(n\), the double factorial, denoted by \(n!!\), is defined as the product of all positive integers not greater than \(n\) that have the same parity as \(n\). Formally, if \(n\) is odd,
\(n!! = n \times (n-2) \times \cdots \times 3 \times 1\),
and if \(n\) is even,
\(n!! = n \times (n-2) \times \cdots \times 4 \times 2\).
For example, \(3!! = 3 \times 1 = 3\) and \(8!! = 8 \times 6 \times 4 \times 2 = 384\). You need to calculate the last 5 digits (in base 10) of \(2021!!\). That is, compute the last five decimal digits of:
\(2021!! = 2021 \times 2019 \times \cdots \times 3 \times 1\).
Subproblem C: Grid Points
A point \((x,y)\) with integer coordinates is called a grid point. A grid point in the first quadrant has \(x > 0\) and \(y > 0\). Determine the number of grid points \((x,y)\) in the first quadrant such that their product does not exceed 2021; i.e., find the number of pairs \((x,y)\) satisfying:
\(x \cdot y \le 2021\).
Subproblem D: Integer Decomposition
An integer decomposition counts the number of ways to write an integer as an ordered sum of positive integers. For example, the number 3 can be decomposed into two positive integers in 2 ways: \(3 = 1 + 2\) and \(3 = 2 + 1\). Also, 5 can be decomposed into three positive integers in 6 ways.
Your task is to determine the number of ordered decompositions of \(2021\) into 5 positive integers. In other words, count the number of solutions to:
\(x_1 + x_2 + x_3 + x_4 + x_5 = 2021, \quad x_i \ge 1\).
Subproblem E: The City-States
There are 2021 city-states numbered from 1 to 2021. Every pair of city-states is connected by a direct bridge. The cost to decorate the bridge between two city-states with numbers \(a\) and \(b\) is computed as follows: Write the decimal representations of \(a\) and \(b\) (treating missing digits as 0) and for each digit position where the two numbers have different digits, add the two differing digits together. For example, for \(a = 2021\) and \(b = 922\) (padded as 2021 and 0922), the differing positions are the thousands, hundreds, and ones digits and the cost is \((2+0) + (0+9) + (1+2) = 14\).
The government plans to decorate exactly 2020 bridges such that the decorated bridges connect all city-states (i.e. the decorated bridges form a spanning tree). You need to determine the minimum total cost required to achieve this.
Input/Output: Each subproblem is a result-fill-in question. The output is a single integer – the computed answer for the subproblem corresponding to the input letter. Extra output will result in no score.
inputFormat
The input consists of a single line containing one uppercase letter: A, B, C, D, or E, representing the subproblem to solve.
outputFormat
Output a single integer – the answer corresponding to the chosen subproblem.
sample
A
1