http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3098
The first line of input contains a single integer N, ( 1
N
1000) which is the number of datasets that follow.
Each dataset consists of a single line of input that contains only eight digits that represent the date of the first day of the last menstrual cycle in format MMDDYYYY.
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 200001
#define mod 10007
#define eps 1e-9
//const int inf=0x7fffffff; //无限大
const int inf=0x3f3f3f3f;
/*
*/
//**************************************************************************************
inline ll read()
{
int x=0,f=1;char ch=getchar();
while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();}
return x*f;
}
int buf[10];
inline void write(int i) {
int p = 0;if(i == 0) p++;
else while(i) {buf[p++] = i % 10;i /= 10;}
for(int j = p-1; j >=0; j--) putchar(‘0‘ + buf[j]);
printf("\n");
}
int month[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int month1[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int check_year(int x)
{
if(x%400==0)
return 1;
if(x%4==0&&x%100!=0)
return 1;
return 0;
}
string check(int x,int y)
{
string ans;
if(x==1)
{
if(y<=20)
{
ans="capricorn";
return ans;
}
else
{
ans="aquarius";
return ans;
}
}
else if(x==2)
{
if(y<=19)
{
ans="aquarius";
return ans;
}
else
{
ans="pisces";
return ans;
}
}
else if(x==3)
{
if(y<=20)
{
ans="pisces";
return ans;
}
else
{
ans="aries";
return ans;
}
}
else if(x==4)
{
if(y<=20)
{
ans="aries";
return ans;
}
else
{
ans="taurus";
return ans;
}
}
else if(x==5)
{
if(y<=21)
{
ans="taurus";
return ans;
}
else
{
ans="gemini";
return ans;
}
}
else if(x==6)
{
if(y<=21)
{
ans="gemini";
return ans;
}
else
{
ans="cancer";
return ans;
}
}
else if(x==7)
{
if(y<=22)
{
ans="cancer";
return ans;
}
else
{
ans="leo";
return ans;
}
}
else if(x==8)
{
if(y<=21)
{
ans="leo";
return ans;
}
else
{
ans="virgo";
return ans;
}
}
else if(x==9)
{
if(y<=23)
{
ans="virgo";
return ans;
}
else
{
ans="libra";
return ans;
}
}
else if(x==10)
{
if(y<=23)
{
ans="libra";
return ans;
}
else
{
ans="scorpio";
return ans;
}
}
else if(x==11)
{
if(y<=22)
{
ans="scorpio";
return ans;
}
else
{
ans="sagittarius";
return ans;
}
}
else if(x==12)
{
if(y<=22)
{
ans="sagittarius";
return ans;
}
else
{
ans="capricorn";
return ans;
}
}
}
int main()
{
int t=read();
for(int cas=1;cas<=t;cas++)
{
string s;
cin>>s;
char ch;
int day=0,mon=0,ye=0;
ch=s[0];
mon+=ch-‘0‘;
ch=s[1];
mon=mon*10+ch-‘0‘;
ch=s[2];
day+=ch-‘0‘;
ch=s[3];
day=day*10+ch-‘0‘;
ch=s[4];
ye+=ch-‘0‘;
ch=s[5];
ye=ye*10+ch-‘0‘;
ch=s[6];
ye=ye*10+ch-‘0‘;
ch=s[7];
ye=ye*10+ch-‘0‘;
int now=0;
while(now<271)
{
now++;
day++;
//cout<<mon<<" "<<day<<" "<<ye<<" "<<now<<endl;
if(check_year(ye))
{
if(day>=month[mon])
{
day=1;
mon++;
if(mon>12)
{
mon=1;
ye++;
}
}
}
else
{
if(day>=month1[mon])
{
day=1;
mon++;
if(mon>12)
{
mon=1;
ye++;
}
}
}
}
if(mon<10)
cout<<cas<<" 0"<<mon;
else
cout<<cas<<" "<<mon;
if(day<10)
cout<<"/0"<<day<<"/"<<ye<<" "<<check(mon,day)<<endl;
else
cout<<"/"<<day<<"/"<<ye<<" "<<check(mon,day)<<endl;
}
}