#P8714. Multiple Result Fill‐in Problems
Multiple Result Fill‐in Problems
Multiple Result Fill‐in Problems
Problem Overview
This contest problem consists of 5 independent result fill‐in questions. Your program should output 5 lines, each line being the answer (an integer) for the corresponding sub‐problem in the order given below.
Problem A: Door Plate Manufacture
A street has 2020 residents with door numbers from 1 to 2020. To make a door plate, the digits 0–9 must be produced and pasted onto the door in order. For example, door number 1017 requires one '0', two '1's and one '7'. Compute the total number of digit 2 characters needed when making all door plates numbered 1 to 2020.
Problem B: Irreducible Fractions
A fraction \(\frac{a}{b}\) is called irreducible if \(\gcd(a,b)=1\). Count the number of irreducible fractions where both numerator and denominator are integers between 1 and 2020 (inclusive).
Problem C: Snake Matrix
A "snake pattern" fills an infinite matrix with positive integers starting from 1 as follows:
1 2 6 7 15 ... 3 5 8 14 ... 4 9 13 ... 10 12 ... 11 ... ... ...
The pattern is constructed by filling the matrix along antidiagonals. For each antidiagonal with index s = i+j, if s is odd, the entries are filled in top-to-bottom order; if s is even, they are filled in bottom-to-top order. For example, the 3-element antidiagonal corresponding to s=4 is filled as: (3,1)=4, (2,2)=5, (1,3)=6. Compute the number at row 20, column 20.
Problem D: Running Exercise
Xiao Lan has been running daily from January 1, 2000 (Saturday) to October 1, 2020 (Thursday), inclusive. On a normal day he runs 1 km. However, if the day is Monday or the first day of a month, he runs 2 km (if a day is both, he still runs 2 km only). Compute the total kilometers run over this period.
Problem E: Seven‐Segment Code
A seven‐segment display has 7 diodes labeled a, b, c, d, e, f, g. A pattern is formed by turning on a nonempty subset of diodes. The pattern is considered valid if all lit diodes form a connected set (in the standard seven‐segment geometry, where adjacent means sharing an edge or touching at a corner, but note that diodes b and f are not adjacent). For example, a single diode (like b or c) is valid, and the set {a,b,c,d,e} is valid, but {b, f} is not. Compute the number of different valid patterns.
Input: There is no input.
Output: Print 5 lines. The first line is the answer for Problem A, the second for Problem B, the third for Problem C, the fourth for Problem D, and the fifth for Problem E. Each answer is an integer.
Note: In your submitted solution, do not output any extra characters.
inputFormat
No input is provided.
outputFormat
Output 5 lines where each line is an integer answer corresponding to Problems A, B, C, D, and E respectively.
sample
624
2480453
761
8877
87
</p>