#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; ll t ; cin >> t ; while (t--) { ll d=0, m=0, y=0, ans=0 ; string date ; string mon="", dat="", year="" ; getline (cin >> ws, date) ; mon=mon+date[5]+date[6] ; m=stoi(mon) ; dat=dat+date[8]+date[9] ; d=stoi(dat) ; year=year+date[0]+date[1]+date[2]+date[3] ; y=stoi(year) ; if(m%2==0 && m!=2) { if(d%2==0) ans=((30-d)/2)+16 ; else ans=((31-d)/2)+16 ; } else if (m==2) { if (y%4==0 && y!=1900) { if(d%2==0) ans=(30-d)/2 ; else ans=((29-d)/2)+1 ; } else { if(d%2==0) ans=(28-d)/2+16 ; else ans=((29-d)/2)+16 ; } } else { if(d%2==0) ans=(32-d)/2 ; else ans=((31-d)/2)+1 ; } cout << ans << endl ; } return 0 ;
}
Asked by: Anonymous on March 29, 2020, 2:03 p.m. Last updated on March 29, 2020, 2:03 p.m.
if y is divisible by 400 , then it is a leap year or if y is div by 4 and not divisible by 100, then it is a leap year
also both july and august have 31 days
ishikachowdhury1998 last updated on March 31, 2020, 1:10 a.m.