Given months per year, days per month and days per week, count calendar rows when each month starts after the previous month and never shares a row.
Easy3SimulationMathInterviewNo attempts yetTime limit5sMemory limit512 MBELG8-G, a planet found outside the Solar System, has a rotation period and an orbital period that differ from Earth's, so Earth's calendar cannot be used there. Scientists decided to design a new calendar system for the planet. The Gregorian calendar used on Earth is awkward because the number of days changes from month to month, so in the new system every month has the same number of days.
The scientists want to print one large calendar to write a daily observation log on, and its size depends on how many months a year holds and how many days a week holds. Write a program that reads those numbers and prints the number of rows the calendar needs.
The calendar is laid out by these rules.
With 11 days in a month, 3 months in a year, and 4 days in a week, the calendar takes 11 rows.
| #0 | #1 | #2 | #3 |
|---|---|---|---|
| 1 | 2 | 3 | 4 |
| 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | |
| 1 | |||
| 2 | 3 | 4 | 5 |
| 6 | 7 | 8 | 9 |
| 10 | 11 | ||
| 1 | 2 | ||
| 3 | 4 | 5 | 6 |
| 7 | 8 | 9 | 10 |
| 11 |
The first line holds the number of test cases T. Each of the next T lines holds one test case as three positive integers M, D, W.
M D W
M is the number of months in a year, D is the number of days in a month, and W is the number of days in a week.
For each test case print one line in the form Case #x: y, where x is the case number starting from 1 and y is the number of rows the calendar needs.