eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Fast Times at Ridgemont`s Planet

Fast Times at Ridgemont`s Planet

NASA has established communications with a new planet discovered by Dr. Ridgemont. This planet, coincidentally, has a calendar very similar to the calendar we use here on Earth. But the minutes, hours, days, and so forth are all of a different duration. For example, on Ridgemont's Planet, a minute might last \textbf{54} seconds, there might be \textbf{61}minutes per hour, \textbf{23} hours per day, and \textbf{340} days per year. The year is split into months, and as on Earth, each month may have a different number of days. The inhabitants have set the calendar this way so that there is no need to handle leap years or daylight savings time, but other than that everything is different. / / - : : NASA software engineers want to practice good code reuse, so naturally they want to port their Linux source code into the communications system they use to talk to the inhabitants on this distant world. Much of their software utilizes the function "difftime", which takes two specifications of a date and time and returns the number of seconds between them. For example, on Earth, if I ask for the difference between \textbf{12:35:00} on one day and \textbf{12:35:15} on the next day, the answer is \textbf{86415}. This represents one day's worth of seconds (\textbf{24} hours times \textbf{60} minutes times \textbf{60}seconds is \textbf{86400}) plus an additional \textbf{15} seconds. All date/time specifications are expressed as a string with the format "\textbf{MMDDYYHHMMSS}". Intuitively, the procedure used by difftime is to determine how many complete days have elapsed between the input specifications and add in the correct number of seconds. Then determine how many more hours are needed, then how many more minutes are needed, and so forth. Example: Suppose that the planet has \textbf{13} months and the number of days in each month as shown in the table below. There are a total of \textbf{399} days in a year. The planet has \textbf{23} hours per day, each hour has \textbf{53} minutes, and each minute has \textbf{61} seconds. A NASA engineer wants to know the difference between \textbf{02/29/11-22:30:05} and \textbf{03/01/1110:00:00}. The calculation performed by difftime might proceed as follows: And in this case the function returns \textbf{108087} "planet seconds". Write a program that reads the characteristics of time on a distant planet and two date/time specifications, and then prints the difference between the two times. You are guaranteed that the first date/time specification is not after the second time. \InputFile There will be an arbitrary number of cases to consider. The input for each case will begin on a new line and consist of a series of values that span one or more lines. Each series will contain the following data items in the order specified, separated by one or more spaces and/or newlines. The allowable range of values for each item is given in parentheses following the item. \begin{itemize} \item The number of seconds in a minute (\textbf{1..100}) \item The number of minutes in an hour (\textbf{1..100}) \item The number of hours in a day (\textbf{1..100}) \item The number of months in a year (\textbf{1..99}), followed by that many integers, each of which represents the number of days in the corresponding month (\textbf{1..99}) \item A start date/time specification in the format \textbf{MM} / \textbf{DD} / \textbf{YY} - \textbf{HH} : \textbf{MM} : \textbf{SS}, without embedded whitespace. \item An end date/time specification in the format \textbf{MM} / \textbf{DD} / \textbf{YY} - \textbf{HH} : \textbf{MM} : \textbf{SS}, without embedded whitespace. \end{itemize} Like on Earth, months and days are numbered starting with one, and years, hours, minutes, and seconds are numbered starting with zero. The series following the input for the last case will contain a single zero. \OutputFile For each case, your program is to print the difference between the start and end date/time specifications in seconds. Each result is to be printed on a line by itself, starting in the first column, without any trailing whitespace.
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
61 53 23 13 30 30 31 31 31 31 31 31 31 31 31 30 30 02/29/11-22:30:05 03/01/11-10:00:00
0
Выходные данные #1
Case 1: 108087 seconds
Источник ACM North Central North America Regional Programming Contest, November 12, 2011