解题思路:
Habb历一年365天
Tzolkin历一年260天
先计算Habb历从第0天到输入日期的总天数sumday
Sumday/day就是Tzolkin历的年份
Tzolkin历的天数Name每20一循环,先建立Tzolkin历天数Name与1~20的映射,
因此Sumday %20+1就是Tzolkin历的天数Name
Tzolkin历的天数ID每13一循环,且从1开始,则Sumday %13+1就是Tzolkin历的天数ID
Java源码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | import java.util.Scanner; public class Main{ public static void main(String[] args) { String[] monthName = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu"}; String[] dayName = {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"}; Scanner in = new Scanner(System.in); int col = Integer.parseInt(in.nextLine()); String[] result = new String[col]; for(int i = 0; i < col; i ++){ String[] ss = in.nextLine().split(" "); int day = Integer.parseInt(ss[0].substring(0, ss[0].length()-1)); String month = ss[1]; int year = Integer.parseInt(ss[2]); int allDay=0,j=0; for(j = 0; j < monthName.length; j++){ if(month.equals(monthName[j])){ break; } } allDay = year*365+j*20+day; result[i] = (allDay%260%13+1)+" "+dayName[allDay%260%20]+" "+(allDay/260); } System.out.println(col); for(String s: result){ System.out.println(s); } } } |
除非注明,饮水思源博客文章均为原创,转载请以链接形式标明本文地址