February
Time Limit: 1000MS |
|
Memory Limit: 32768KB |
|
64bit IO Format: %lld &%llu |
Submit Status
Description
It is, and it's a leap year. So there was a "February" in the year, which was called Leap Day. Interesting thing is the infant who'll born in this February, would get his/her birthday again in, which is Anoth ER leap year. So February is exists in leap years. Does leap year comes in every 4 years? Years that is divisible by 4 is leap years, but years that is divisible by is not leap years, unless they is divi Sible by + which case they is leap years.
In this problem, you'll be given and different date. You have to find the number of leap days in between them.
Input
Input starts with an integer T (≤550), denoting the number of test cases.
Each of the test cases would have a lines. First line represents the first date and second line represents the second date. Note that, the second date would not represent a date which arrives earlier than the first date. The dates'll is in this format- "Month day, year", see sample input for exact format. You is guaranteed that dates would be valid and the year would be in between 2 * 103 to 2 * 109. For your convenience, the month list and the number of days per months is given below. You can assume this all the given dates would be a valid date.
Output
For each case, print the case number and the number of leap days in between, given dates (inclusive).
Sample Input
4
January 12, 2012
March 19, 2012
August 12, 2899
August 12, 2901
August 12, 2000
August 12, 2005
February 29, 2004
February 29, 2012
Sample Output
Case 1:1
Case 2:0
Case 3:1
Case 4:3
Source
Problem setter:md. Arifuzzaman arifspecial thanks:jane Alam Jan
#include <map>#include<cstdio>#include<iostream>using namespaceStd;map<string,int>MP;Charmonth[ -][ -]={"January", "February","March","April", " May","June","July","August", "September","October","November", "December"}; BOOLJudgeinty) { if((y%4==0&& y% -!=0) || y% -==0) return true; return false;}intMain () { for(intI=0; i< A; i++) Mp[month[i]]= i+1; intT, q=1; scanf"%d", &t); while(t--) { Chara[ -]; intm, y; scanf ("%s%d,%d", A, &m, &y); intt1=0, t2 =0; intbb=Mp[a]; if(judge (y)) {if(bb>2) y++; } y--; T1+=y/4-y/ -+y/ -; scanf ("%s%d,%d", A, &m, &y); if(judge (y)) {if(mp[a]>2|| (mp[a]==2&& m== in)) Y++; } y--; T2= t2+y/4-y/ -+y/ -; printf ("Case %d:%d\n", q++, t2-t1); } return 0;}
lightoj-1414 February 29