| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
菜鸟弱问1008TLE了……程序本身写得比较弱,大家见笑了,大牛们方便的话发几个短小精干的Source code我看看,不胜感激……
#include<iostream>
#include<string>
using namespace std;
void main()
{
int hyear=0,tmp=0,hday=0,tyear=0,tdays=0,count=0,id1=0,id2=0,num=0;
string hmonth,tmphday;
int totalDays[100];
for(int k=0;k<100;k++)
{
totalDays[k]=0;
}
cin>>num;
for(int i=0;i<num;i++)
{
cin>>tmphday>>hmonth>>hyear;
tmphday.erase(tmphday.find("."));
if(tmphday=="0")
hday=1;
else if(tmphday=="1")
hday=2;
else if(tmphday=="2")
hday=3;
else if(tmphday=="3")
hday=4;
else if(tmphday=="4")
hday=5;
else if(tmphday=="5")
hday=6;
else if(tmphday=="6")
hday=7;
else if(tmphday=="7")
hday=8;
else if(tmphday=="8")
hday=9;
else if(tmphday=="9")
hday=2;
else if(tmphday=="10")
hday=11;
else if(tmphday=="11")
hday=12;
else if(tmphday=="12")
hday=13;
else if(tmphday=="13")
hday=14;
else if(tmphday=="14")
hday=15;
else if(tmphday=="15")
hday=16;
else if(tmphday=="16")
hday=17;
else if(tmphday=="17")
hday=18;
else if(tmphday=="18")
hday=19;
else if(tmphday=="19")
hday=20;
if(hmonth.find("pop")!=string::npos)
tmp=0;
else if(hmonth.find("no")!=string::npos)
tmp=20;
else if(hmonth.find("zip")!=string::npos)
tmp=40;
else if(hmonth.find("zotz")!=string::npos)
tmp=60;
else if(hmonth.find("tzec")!=string::npos)
tmp=80;
else if(hmonth.find("xul")!=string::npos)
tmp=100;
else if(hmonth.find("yoxkin")!=string::npos)
tmp=120;
else if(hmonth.find("mol")!=string::npos)
tmp=140;
else if(hmonth.find("chen")!=string::npos)
tmp=160;
else if(hmonth.find("yax")!=string::npos)
tmp=180;
else if(hmonth.find("zac")!=string::npos)
tmp=200;
else if(hmonth.find("ceh")!=string::npos)
tmp=220;
else if(hmonth.find("mac")!=string::npos)
tmp=240;
else if(hmonth.find("kankin")!=string::npos)
tmp=260;
else if(hmonth.find("muan")!=string::npos)
tmp=280;
else if(hmonth.find("pax")!=string::npos)
tmp=300;
else if(hmonth.find("koyab")!=string::npos)
tmp=320;
else if(hmonth.find("cumhu")!=string::npos)
tmp=340;
totalDays[i]=hyear*365+tmp+hday;
}
cout<<num<<endl;
for(i=0;i<num;i++)
{
tyear=totalDays[i]/260;
tdays=totalDays[i]-260*tyear;
count=id1=id2=0;
while(count!=tdays)
{
count++;
id1++;
id2++;
if(id1==14)
{
id1=1;
}
if(id2==21)
{
id2=1;
}
}
if(id1==0||id2==0)
{
id1=id2=1;
}
string tmonth;
if(id2==1)
tmonth="imix";
else if(id2==2)
tmonth="ik";
else if(id2==3)
tmonth="akbal";
else if(id2==4)
tmonth="kan";
else if(id2==5)
tmonth="chicchan";
else if(id2==6)
tmonth="cimi";
else if(id2==7)
tmonth="manik";
else if(id2==8)
tmonth="lamat";
else if(id2==9)
tmonth="muluk";
else if(id2==10)
tmonth="ok";
else if(id2==11)
tmonth="chuen";
else if(id2==12)
tmonth="eb";
else if(id2==13)
tmonth="ben";
else if(id2==14)
tmonth="ix";
else if(id2==15)
tmonth="mem";
else if(id2==16)
tmonth="cib";
else if(id2==17)
tmonth="caban";
else if(id2==18)
tmonth="eznab";
else if(id2==19)
tmonth="canac";
else if(id2==20)
tmonth="ahau";
cout<<id1<<" "<<tmonth<<" "<<tyear<<endl;
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator