#P8713. Multi-Part Mathematical Puzzles
Multi-Part Mathematical Puzzles
Multi-Part Mathematical Puzzles
This problem consists of 5 independent puzzles. You are given a single uppercase letter among A, B, C, D, or E as input. Depending on the chosen letter, output the answer for the corresponding puzzle. Any extra output will be considered incorrect.
Problem A: Doorplate Manufacture
On a street there are 2020 houses numbered from 1 to 2020. To make a doorplate with a given number, the digit characters (0–9) are individually prepared and then pasted on the door in order. For example, to create the doorplate for 1017, you need one '0', two '1's, and one '7'. Determine the total number of digit 2 required to produce doorplates for all houses from 1 to 2020.
Problem B: Reduced Fractions
A fraction \(\frac{p}{q}\) with \(1 \le p,q \le 2020\) is called reduced if \(\gcd(p,q)=1\). Count how many reduced fractions exist where both numerator and denominator lie in the range 1 to 2020 (inclusive).
Problem C: Snake Filling
An infinite matrix is filled with the positive integers in a "snake-like" pattern as shown below:
[ \begin{array}{cccccc} 1 & 2 & 6 & 7 & 15 & \ldots \ 3 & 5 & 8 & 14 & \ldots & \ 4 & 9 & 13 & \ldots & & \ 10 & 12 & \ldots & & & \ 11 & \ldots & & & & \ \ldots & & & & & \end{array} ]
For instance, the entry in the second row and second column is 5. Compute the number in the 20th row and 20th column.
Problem D: Seven-Segment Codes
A seven‐segment display has 7 light‐up diodes labeled a, b, c, d, e, f, g arranged as shown below:
Each character is represented by lighting a nonempty subset of these diodes, with the constraint that the lit diodes must form a connected block. For example, lighting just b is valid. However, lighting b and f is not valid because they are not adjacent (even though both light individually yield valid but distinct characters). Determine the total number of distinct characters that can be represented.
Problem E: Plane Division
What is the maximum number of regions into which 20 circles and 20 straight lines can divide the plane?
Input/Output Protocol: This is a result‐only answer problem. When submitting your solution, you only need to output the correct integer corresponding to the puzzle indicated by the input letter.
Summary of Answers:
- A: 624
- B: 2479999
- C: 761
- D: 95
- E: 1392
inputFormat
Your program reads from standard input a single uppercase letter: A
, B
, C
, D
, or E
. This letter indicates which puzzle's answer to output.
outputFormat
Output a single integer — the answer corresponding to the selected puzzle. No extra output is allowed.
sample
A
624