Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You should complete the function and ensure it produces the correct output against all test cases possible within the constraints highlighted. The runtime of the
You should complete the function and ensure it produces the correct output against all test cases possible within the constraints highlighted. The runtime of the program is important so it is best to use an algorithm in the code which will not timeout. Please to solve it as soon as possible
Secret Dates Problem Submissions Leaderboard Discussions The math club at a high school decides to publicize its meeting times by posting them on the school's notice board. However, as a challenge to their members, they decide to encrypt it in a way that will challenge their club members and stimulate interest in the club. The message posted always starts with three integers. The first two are the key, k and the modulus, m and the third is the number of meeting dates, n. Following that will be n enciphered dates, d1,...,dr, each on a different line. Contest ends in 6 days Submissions: 2 Max Score: 25 Difficulty: Medium Rate This Challenge: To obtain the enciphered date, they use the following procedure: More Write down the date and time of the meeting as a 7- or 8-digit number formed by concatenating the digits of the date when written numerically in the format Month-Day- Hour-Minute (the hour is encoded in 24 hour format), with 2 digits per field. For example the date December 1 at 4:25pm in the format would be 12-01-16-25, and would be encoded by concatenating those 2-digit numbers to obtain: 12011625 Initialise an accumulator to 0 Repeat k times: add the numerical date to the accumulator, and reduce the value modulo m m Output the value in the accumulator as the enciphered date. (If the month number is less than 10, they don't bother writing the leading zero, since it doesn't affect the value of the number.) For example, suppose that the key, k, is 5, the modulus, m is 20,000,003 and the dates to be encoded are as given in the first row of the table below. The rows in the table show the intermediate values obtained during the ecipherment of the dates. The last row shows the final enciphered value for each date. Those enciphered values would be output to the message. Heading Date 1 Date 2 Date 3 Dates: Dec. 1, 4:25pm Jan 4, 9:15am Apr. 29, 12:31am 12011625 1040915 4290031 Numerical Encoding: Initial Acc 0 0 0 Pass 1 12011625 1040915 4290031 Pass 2 2081830 8580062 (12011625 + 12011625) mod 20000003-4023247 Pass 3 (4023247 +12011625) mod 20000003 = 16034872 3122745 12870093 Pass 4 4163660 17160124 (16034872 + 12011625) mod 20000003 = 8046494 (8046494 + 12011625) mod 20000003 =58116 Pass 5 5204575 1450152 For a given message, determine the dates that are enciphered, and output the earliest date (Jan 1, midnight is earliest possible) as a single integer. Input Format Line 1: k m n each value being an integer Each of the following n lines contains a single enciphered date, di:1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started