每年的最后一天要考虑
#include <fstream> #include <string> #include <map> using namespace std;
int main() { int n , i ; scanf("%d" , &n ) ; int hdd , hyy , tdd[n] , tnn[n] , tyy[n] , total , day ; char pp,hmon[7] , tname[21][9] = { "oooo" , "imix" , "ik" , "akbal" , "kan" , "chicchan" , "cimi" , "manik" , "lamat" , "muluk" , "ok" , "chuen" , "eb" , "ben" , "ix" , "mem" , "cib" , "caban" , "eznab" , "canac" , "ahau" }; map<string, int> hmm ; hmm["pop"] = 0; hmm["no"] = 1; hmm["zip"] = 2; hmm["zotz"] = 3; hmm["tzec"] = 4; hmm["xul"] = 5; hmm["yoxkin"] = 6; hmm["mol"] = 7; hmm["chen"] = 8; hmm["yax"] = 9; hmm["zac"] = 10; hmm["ceh"] = 11; hmm["mac"] = 12; hmm["kankin"] = 13; hmm["muan"] = 14; hmm["pax"] = 15; hmm["koyab"] = 16; hmm["cumhu"] = 17; hmm["uayet"] = 18; for ( i = 0 ; i < n ; i++) { scanf("%d%c %[^ ] %d", &hdd , &pp , hmon , &hyy ); total = 1 + hdd + hmm[hmon] * 20 + hyy * 365; tyy[i] = total / 260 ; day = total % 260 ; if ( day == 0 ) tyy[i]-- ; tdd[i] = day % 13 ; if ( tdd[i] == 0 ) tdd[i] = 13 ; tnn[i] = day % 20 ; if ( tnn[i] == 0 ) tnn[i] = 20 ; } printf("%d\n",n); for ( i = 0 ; i < n ; i++) printf("%d %s %d\n" , tdd[i] , tname[tnn[i]] , tyy[i] ); return 0; }