Sunday, May 1, 2016

11219 - How old are you?

#include<bits/stdc++.h>
#define i64 long long
#define mx(a,b,c) max(a,max(b,c))
#define mn(a,b,c) min(a,min(b,c))
#define eef else if
#define ff(i,s,e) for(int i=(s); i<e; i++)
#define ff2(i,s,e) for(int i=(s); i>=e; i--)
#define sf scanf
#define pf printf
#define dbug(x) cout<<"x = "<<x<<endl
#define newl cout<<"\n"
#define putcase cout<<"Case "<<++cse<<":"
#define putcase2 cout<<"Case #"<<++cse<<":"
using namespace std;
int main()
{
   int t,cse=0;
   cin>>t;
   while(t--){
    double birthSum=0;
    double todaySum=0;
    double bd , bm , by,cd,cm,cy;
    char c;
    cin>>bd>>c>>bm>>c>>by>>cd>>c>>cm>>c>>cy;
    birthSum=(cy*365)+(cm*30)+cd;
    todaySum=(by*365)+(bm*30)+bd;
    if((todaySum-birthSum)<0){
        putcase2;
        cout<<" Invalid birth date\n";
    }
    else if(((todaySum-birthSum)/365.00)>=131){
        putcase2;
        cout<<" Check birth date\n";
    }
    else{
        putcase2;
        cout<<" "<<(int)((todaySum-birthSum)/365.00)<<endl;
    }
   }
    return 0;
}

No comments:

Post a Comment