#P8704. Multi‐Task Contest Problem: A, B, C, D and E

    ID: 21868 Type: Default 1000ms 256MiB

Multi‐Task Contest Problem: A, B, C, D and E

Multi‐Task Contest Problem: A, B, C, D and E

This contest problem consists of five subtasks. Your program will be given a single input which is a capital letter among A, B, C, D and E that indicates which subtask to solve. The details of each subtask are as follows:

Subtask A: Running Training

Little Ming begins a running training with an initial stamina of \(10000\). While running, his stamina decreases uniformly at a rate of \(600\) per minute; while resting, it increases uniformly at \(300\) per minute. He alternates one minute of running and one minute of resting. However, if at any moment his stamina reaches \(0\), he stops training immediately. Compute the total training time (in seconds). (Note that the answer is guaranteed to be an integer number of seconds.)

Subtask B: Pooled Testing

In country A, due to a shortage of test kits for COVID‐19, scientists have devised a pooled testing method. In a group of \(k\) people, the samples are mixed in one test kit. If the pooled test is negative, all \(k\) persons are negative. If positive, all \(k\) samples must be tested separately, in addition to the pooled test (i.e. \(k+1\) kits are used). Given an estimated infection rate of \(1\%\) (with independent, uniform distribution), determine the value of \(k\) that minimizes the expected number of test kits used per group.

Subtask C: Mask Allocation

A mayor has received several batches of masks with quantities

masks = [9090400, 8499400, 5926800, 8547000, 4958200, 4422600,
         5751200, 4175600, 6309600, 5865200, 6604400, 4635000,
         10663400, 8087200, 4554000]

Due to logistical constraints, each batch must be allocated entirely to one of two hospitals. The goal is to minimize the absolute difference between the total masks received by the two hospitals. Compute this minimum difference.

Subtask D: Matrix Arrangements

Fill a \(2\times 1010\) matrix with the numbers \(1,2,3,\dots,2020\) (each number used exactly once) such that in each row the numbers increase from left to right and in each column the numbers increase from top to bottom. Because the total number of arrangements may be enormous, output the answer modulo \(2020\). (Hint: the answer can be shown to equal the Catalan number \(C_{1010}\) modulo \(2020\).)

Subtask E: Perfect Square Number

We call a nonnegative integer \(X\) a perfect square number if:

  • \(X\) itself is a perfect square, and
  • every digit of \(X\) is also a perfect square (i.e. each digit is one of \(0, 1, 4, 9\)).

For example, the first several perfect square numbers are: \(0,1,4,9,49,100,144,\dots\). Compute the 2020th perfect square number.

Input Format: The input consists of a single capital letter (A, B, C, D or E) on one line.

Output Format: Output the answer for the corresponding subtask. For subtask A, output the number of seconds (an integer) without any unit; for B output the optimal integer value of \(k\); for C output the minimum absolute difference; for D output the arrangement count modulo \(2020\); and for E output the 2020th perfect square number.

Note: It is guaranteed that the answer for subtask A is an integer.

inputFormat

A single line containing one of the letters A, B, C, D, or E.

outputFormat

Output a single integer which is the answer for the corresponding subtask. Do not print any extra characters or spaces.

sample

A
3970