#include<bits/stdc++.h>
using namespace std;
int main()
{
long ts,cs=1;
cin>>ts;
while(ts--)
{
string s,month,ss[15]= {"January","February","March","April","May","June","July","August","September","October","November","December"};;
long mon[15]= {31,28,31,30,31,30,31,31,30,31,30,31};
long i,n,year=0,date=0;
cin>>s>>n;
long sz=s.size();
for(i=0; i<4; i++)
{
year=year*10+(s[i]-48);
}
for(i=5; i<sz-3; i++)
{
month+=s[i];
}
date=(s[sz-2]-48)*10+(s[sz-1]-48);
date+=n;
long flag=0;
for(i=0; i<12; i++)
{
if((year%4==0&&year%100!=0)||(year%400==0))
mon[1]=29;
else
mon[1]=28;
if(ss[i]==month)
{
flag=1;
if(date<=mon[i])
break;
else
date-=mon[i];
}
if(i==11)
{
i=-1;
year++;
}
if(flag==1)
{
month=ss[i+1],flag=0;
}
}
printf("Case %ld: ",cs++);
cout<<year<<"-"<<month<<"-";
if(date<10)
cout<<0;
cout<<date<<endl;
// cout<<date<<" "<<month<<" "<<year<<endl;
}
}
using namespace std;
int main()
{
long ts,cs=1;
cin>>ts;
while(ts--)
{
string s,month,ss[15]= {"January","February","March","April","May","June","July","August","September","October","November","December"};;
long mon[15]= {31,28,31,30,31,30,31,31,30,31,30,31};
long i,n,year=0,date=0;
cin>>s>>n;
long sz=s.size();
for(i=0; i<4; i++)
{
year=year*10+(s[i]-48);
}
for(i=5; i<sz-3; i++)
{
month+=s[i];
}
date=(s[sz-2]-48)*10+(s[sz-1]-48);
date+=n;
long flag=0;
for(i=0; i<12; i++)
{
if((year%4==0&&year%100!=0)||(year%400==0))
mon[1]=29;
else
mon[1]=28;
if(ss[i]==month)
{
flag=1;
if(date<=mon[i])
break;
else
date-=mon[i];
}
if(i==11)
{
i=-1;
year++;
}
if(flag==1)
{
month=ss[i+1],flag=0;
}
}
printf("Case %ld: ",cs++);
cout<<year<<"-"<<month<<"-";
if(date<10)
cout<<0;
cout<<date<<endl;
// cout<<date<<" "<<month<<" "<<year<<endl;
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন