Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int isleap(int year)
- {
- if(year % 400 == 0)
- return 1;
- else if(year % 100 == 0)
- return 0;
- else if(year % 4 == 0)
- return 1;
- else return 0;
- }
- int main()
- {
- long test, years[100000] = {0}, sum = 0;
- for(long i = 1004; i < 100000; i++)
- {
- sum = sum + isleap(i);
- years[i] = sum;
- }
- string bdyy;
- scanf("%d", &test);
- getline(cin, bdyy);
- for(int i = 0; i < test; i++)
- {
- string init_str, late_str, ul;
- string jan ("January");
- string feb ("February");
- char ch;
- long init_mm, init_yyyy, late_mm, late_yyyy, yr1, yr2;
- cin>>init_str>>init_mm>>ch>>init_yyyy;
- getline(cin, ul);
- cin>>late_str>>late_mm>>ch>>late_yyyy;
- getline(cin, ul);
- // cout<<init_yyyy<<" "<<late_yyyy<<endl;
- // cout << jan << endl;
- if(init_str.compare(jan) == 0 || init_str.compare(feb) == 0)
- {
- yr1 = init_yyyy;
- }
- else
- {
- yr1 = init_yyyy + 1;
- }
- if(late_str.compare(jan) == 0)
- {
- // cout<<"baal"<<endl;
- yr2 = late_yyyy - 1;
- }
- else if(late_str.compare(feb) == 0)
- {
- // cout<<"baal"<<endl;
- if(late_mm == 29)
- yr2 = late_yyyy;
- else
- yr2 = late_yyyy - 1;
- }
- else
- {
- yr2 = late_yyyy;
- }
- if(yr1 == yr2)
- {
- printf("Case %d: %ld\n", i + 1, isleap(yr1));
- }else printf("Case %d: %ld\n", i + 1, years[yr2] - years[yr1 - 1]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement