Millennium
Time limit1sMemory limit128 MB
Given a birthdate in a fictional 10-month calendar with alternating 19 and 20 day months, find days until year 1000, month 1, day 1.
- Level
Easy3 of 10
- Topics
- Math, Implementation, Simulation, Prefix sum
- Solved
- No attempts yet
Problem
A wise king proclaimed a new calendar. “Let tomorrow be the first day of this calendar, that is, day 1 of month 1 of year 1. A year has ten months, from month 1 through month 10, and begins with a big month. A common year begins with a big month, after which small months and big months alternate. Thus month 1 is a big month, month 2 a small month, month 3 a big month, …, and the last month, month 10, a small month. A big month has 20 days and a small month has 19 days. However, years that are multiples of three, that is years 3, 6, 9, and so on, have ten big months and no small month.”
Many years have passed since the calendar came into use. To celebrate the millennium day (year 1000, month 1, day 1), a royal lottery will be held to send gifts to those who have lived exactly as many days as the number drawn. Write a program that, given a birthdate, computes the number of days from that birthdate to the millennium day.
Input
The input is given in the following format.
n
Y1 M1 D1
Y2 M2 D2
...
Yn Mn Dn
The first line contains a positive integer (at most 100), the number of datasets. It is followed by datasets. Each dataset is a single line containing three positive integers (), (), and () — the year, month, and day of a person's birthdate in the king's calendar — separated by spaces.
Output
For each birthdate, print on its own line the number of days from the birthdate, inclusive, to the millennium day, exclusive. Each output line must contain nothing but this number.