On our planet, Jamcode IX, three Great Events occurred. They happened 26,000, 11,000, and 6,000 slarboseconds ago. In 4,000 slarboseconds, the amount of time since all of those events will be multiples of 5,000 slarboseconds, the largest possible amount... and the apocalypse will come.
Luckily for you, you live on Jamcode X! The apocalypse came on Jamcode IX less than a year ago. But Jamcode X has a worrying prophecy: "After the moment of reckoning, on the first optimum anniversary of the
The people of Jamcode X are very concerned by this prophecy. All of the Great Events have already happened, and their times have been measured to the nearest slarbosecond; but nobody knows when their optimum anniversary will occur. After studying the diary of a scientist from Jamcode IX, scientists working on the problem have come up with a theory:
The moment of reckoning is now, the moment you solve this problem. At some time
On Jamcode IX, for example, there were 3 Great Events and they happened
Your job is to compute the amount of time until the apocalypse comes. But remember the prophecy: even though the people of Jamcode X have been solving problems for two years, and 64-bit integers have always been enough, they might not always be enough now or in the future.
Input Specification
The first line of the input gives the number of test cases,
Output Specification
For each test case, output one line containing Case #x: y
, where
Limits
Time limit: 30 seconds per test set.
Memory limit: 1GB.
Small dataset
Large dataset
Sample Input
3
3 26000000 11000000 6000000
3 1 10 11
2 800000000000000000001 900000000000000000001
Sample Output
Case #1: 4000000
Case #2: 0
Case #3: 99999999999999999999
Epilogue
Fortunately for the peoples of the Jamcode system, "the apocalypse" turned out to be a mistranslation of "the giant party." Nobody from Jamcode IX bothered to pass this along, because they were having so much fun.
Comments