#P8691. Multi-Problem Calculation Challenge

    ID: 21857 Type: Default 1000ms 256MiB

Multi-Problem Calculation Challenge

Multi-Problem Calculation Challenge

This contest problem consists of five sub‐problems. You will be given a single uppercase letter as input – one of A, B, C, D, or E. Depending on the input, you are to output an integer answer corresponding to the following tasks:

Problem A: Odd Multiple

Find the smallest positive integer \(X\) such that:

  • \(X\) is a multiple of 2019, i.e. \(X = 2019\cdot n\) for some integer \(n \ge 1\).
  • Every digit of \(X\) is an odd digit (i.e. 1, 3, 5, 7, 9).
For example, if you test \(X = 2019\), it contains even digits and hence does not qualify. Your program must compute \(X\) by checking successive multiples of 2019.

Problem B: Increasing Sequences

Consider a letter matrix. A increasing sequence is defined as a pair of letters in the same row, column, or on the same 45° diagonal (with the two possible orders for anti-diagonals being considered separately) such that when read in the proper order (left‐to‐right for rows, top‐to‐bottom for columns, and as defined for diagonals), the two letters are strictly in increasing alphabetical order. For example, in the following 2×4 matrix:

LANN
QIAO
there are 13 increasing sequences: LN, LN, AN, AN, IO, AO, LQ, AI, NO, NO, AQ, IN, AN. Output the number 13.

Problem C: Square Splitting

Express 2019 as a sum of several pairwise distinct perfect squares. Count the number of different ways to do this. Note that the order of summands does not matter; for example, \(13^2 + 25^2 + 35^2 = 2019\) is considered the same as any permutation of these terms. You are to output the count (an integer) of the representations.

Problem D: Optimal Travel

Xiao Ming plans to travel by high‐speed train. Starting from Beijing at 12:00 on day 1, he will visit the following 19 cities exactly once: Shanghai, Guangzhou, Changsha, Xi'an, Hangzhou, Jinan, Chengdu, Nanjing, Kunming, Zhengzhou, Tianjin, Taiyuan, Wuhan, Chongqing, Nanchang, Changchun, Shenyang, Guiyang, and Fuzhou, and then return to Beijing. Furthermore, in every city (except Beijing) he must stay at least 24 hours (i.e. at least 1440 minutes). He will only travel along direct high‐speed train connections as given in the attached file trip.txt. Compute the minimum total time (in minutes) needed to complete his trip. (For this problem output the pre‐computed integer.)

Problem E: Dice Manufacturing

Dice are standard six-faced cubes with faces numbered 1 through 6. In the standard design the patterns for 1, 4, and 5 are invariant under rotations of 90°, 180°, or 270° while the patterns for 2, 3, and 6 are invariant only under a 180° rotation. Xiao Ming wants to manufacture dice such that for each die, any two rotations (of the full cube) yield different appearances. Determine the maximum number of dice he can produce under this constraint. (Output the pre‐computed integer.)

Input: A single uppercase letter, one of {A, B, C, D, E}, indicating which problem to solve.
Output: A single integer – for problems A, C, D, and E, your program must compute (or output) the corresponding answer; for problem B, output 13.

Note: For problems A, C, D and E, the answer is determined by a computation (or pre‐calculation) and the output should contain only the integer result. Extra output will be considered incorrect.

inputFormat

A single uppercase letter ('A', 'B', 'C', 'D', or 'E') representing which sub-problem to solve.

outputFormat

A single integer which is the answer to the corresponding sub-problem.

sample

A
x