直接手动打表。。。
虽然很蠢
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll i,n,y,m,d,rq; ll t=2000; ll mo[102]={14,13,12,11,9,8,14,13,11,10,9,8,13,12,11,10,8,14,13,12,10,9,8,14,12,11,10,9,14,13,12,11,9,8,14,13,11,10,9,8,13,12,11,10,8,14,13,12,10,9,8,14,12,11,10,9,14,13,12,11,9,8,14,13,11,10,9,8,13,12,11,10,8,14,13,12,10,9,8,14,12,11,10,9,14,13,12,11,9,8,14,13,11,10,9,8,13,12,11,10,9,8}; ll mother[102]; ll father[102]; ll fa[102]={18,17,16,15,20,19,18,17,15,21,20,19,17,16,15,21,19,18,17,16,21,20,19,18,16,15,21,20,18,17,16,15,20,19,18,17,15,21,20,19,17,16,15,21,19,18,17,16,21,20,19,18,16,15,21,20,18,17,16,15,20,19,18,17,15,21,20,19,17,16,15,21,19,18,17,16,21,20,19,18,16,15,21,20,18,17,16,15,20,19,18,17,15,21,20,19,17,16,15,21,20,19}; char s[5]; int main(int argc, char * argv[]) { cin>>n; for(i=0;i<102;i++) { mother[i]=mo[i]+t*10000+5*100; father[i]=fa[i]+t*10000+6*100; t++; //printf("%lld %lld \n",mother[i],father[i]); } while(n--){ cin>>y>>m>>d; rq=y*10000+m*100+d*1; if(rq>20000100 && rq<20000514) printf("Mother's Day: May 14th, 2000\n"); else if (rq>=20000514 && rq<20000618) printf("Father's Day: June 18th, 2000\n"); else{ for(i=1;i<102;i++) { if(rq>=mother[i] && rq<father[i]) { d=father[i]%100; y=father[i]/10000; if(d==1 || d==21 || d==31 ) {s[0]='s';s[1]='t';} else if(d==2 || d==22 || d==32 ) {s[0]='n';s[1]='d';} else if(d==3 || d==23 || d== 33 ) {s[0]='r';s[1]='d';} else {s[0]='t'; s[1]='h'; } printf("Father's Day: June %lld%s, %lld\n",d,s,y); } else if(rq>=father[i-1] && rq<mother[i]) { d=mother[i]%100; y=mother[i]/10000; if(d==1 || d==21 || d==31 ) {s[0]='s';s[1]='t';} else if(d==2 || d==22 || d==32 ) {s[0]='n';s[1]='d';} else if(d==3 || d==23 || d== 33 ) {s[0]='r';s[1]='d';} else {s[0]='t'; s[1]='h'; } printf("Mother's Day: May %lld%s, %lld\n",d,s,y);} } } } return 0; }