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

Effective Infection Time

Effective Infection Time

You are estimating the threat level of quarantined zones that have been abandoned to the infection. One of the key variables in determining a zone's threat level is the EIT (Effective Infection Time). This information is essential for planning strike dates to reclaim quarantined zones. The EIT is calculated according to the following rules: \begin{itemize} \item The EIT is the result of a function of two dates: The infection date and the strike date. \item All years are in A.Z. (After Zombie). \item Every month counts for a fraction of an EIT after its last day has passed. This means the month of the strike date does not count for EIT. \item The first calendar year of the infection is calculated as 1/2 EIT. \begin{itemize} \item If the end of the year is not reached, each month only counts for a fraction of the 1/2 EIT. If a zone was infected in January of the first year, then the 1/2 EIT is spread across 12 months ((1/2)/12 = ~ 0.0417 EIT per month). If a zone was infected in March of the first year, then the 1/2 EIT is spread across 10 months ((1/2)/10 = 0.0500 EIT per month). \item If the end of the year is reached, the year counts as a full 1/2 EIT, regardless of the infection month. In other words, a zone infected in February of 15 A.Z. counts as only 1/2 (one-half) EIT after December 15 A.Z. A zone infected in December of the same year will also count as 1/2 EIT. \end{itemize} \item All following years are calculated as 1 EIT. Each calendar month, beginning with January, counts for 1/12 EIT (~ 0.0833 EIT). \item Every zone infected on the same month will have the same EIT for any given strike date. Therefore only the month and year are given. \end{itemize} \textit{The number and order of months in a calendar year remains the same as the modern Gregorian calendar.} \InputFile The first line will be an integer \textbf{N}, where \textbf{1} ≤ \textbf{N} ≤ \textbf{50} giving the number of zones. For each zone, a pair of lines of will be provided: \begin{itemize} \item The first line contains the infection date. The second contains the strike date. \item The first integer of a date represents the month, \textbf{M} (\textbf{1} ≤ \textbf{M} ≤ \textbf{12}), and the second integer represents the year, \textbf{Y} (\textbf{0000} ≤ \textbf{Y} ≤ \textbf{0030}). The year will always have \textbf{4} digits. \item The strike date will never precede the infection date. \end{itemize} \OutputFile Output the EIT for each zone on its own line. The EIT must be rounded to the fourth digit after the decimal point. The ones-digit must always be printed even if it is a zero.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
2
2 0009
11 0012
3 0010
10 0010
Вихідні дані #1
3.3333
0.3500
Джерело ACM ICPC South Central USA Regional Programming Contest 2013