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 |
//一年的最后一天这种特殊情况要考虑 //要打印测试用例数 //月份名字不要写错了#include <iostream> #include <stdio.h> #include <vector> #include <map> #include <string> //一年的最后一天的特殊情况要考虑 //要打印测试用例数 //月份名字不要写错了 using namespace std; const string Haab_monthnames[19] = {"pop","no","zip","zotz","tzec","xul","yoxkin","mol", "chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"}; const string Tzolkin_days[20] = {"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"}; int main() { map<string, int> Haab_months; for (int i = 0; i < 19; i++) { string str = Haab_monthnames[i]; Haab_months[str] = i; } int n; string date,month; int year; cin >> n; cout << n << endl; for (int id = 0; id < n; id++) { cin >> date >>month>> year; string v = ""; int day = 0; for (int j = 0; j < date.length(); j++) { if (date[j] == '.') break; v.push_back(date[j]); } for (int i = 0; i < v.length(); i++) { day = day * 10 + v[i] - '0'; } int days = year * 365 + Haab_months[month] * 20 + day+1; int Tzolkin_year = days / 260; int Tzolkin_date = days % 260; if (Tzolkin_year > 0 && Tzolkin_date == 0) { Tzolkin_year--; Tzolkin_date = 260; } int Tzolkin_month = Tzolkin_date % 13; if (Tzolkin_month == 0) Tzolkin_month = 13; int Tzolkin_day = Tzolkin_date % 20; if (Tzolkin_day == 0) Tzolkin_day = 20; string T_d = Tzolkin_days[Tzolkin_day-1]; cout << Tzolkin_month << ' ' << T_d << ' ' << Tzolkin_year << endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator