? ? ? 不同计年方法之间的转化,我的思路是:根据各自计年方法的定义,将一种计年方法换算成总天数,再将总天数转化为令一种计年方法。
import java.util.*; import java.io.*; //1008 Maya Calendar public class Main { static final String[] Haab = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet"}; static final String[] Tzolkin = {"imix", "ik", "akbal","kan","chicchan", "cimi","manik","lamat","muluk","ok","chuen", "eb","ben","ix","mem","cib","caban","eznab","canac","ahau"}; public static void main(String[] args) throws Exception { Scanner in = new Scanner(new BufferedInputStream(System.in)); String line = in.nextLine(); System.out.println(line); int countOfCase = Integer.parseInt(line); int dotPos, lastSpacePos, num, month, year, worldDay; while(countOfCase-- > 0) { worldDay = 0; line = in.nextLine(); dotPos = line.indexOf('.'); lastSpacePos = line.lastIndexOf(' '); num = Integer.parseInt(line.substring(0, dotPos)); month = getMonth(line.substring(dotPos+2, lastSpacePos)); year = Integer.parseInt(line.substring(lastSpacePos+1)); worldDay += (year*365 + num); if(month > 0) worldDay += month*20; System.out.printf("%d %s %d\n", (worldDay%260)%13 + 1, Tzolkin[(worldDay%260)%20], worldDay/260); } } public static int getMonth(String monthStr) { for(int i = 0; i < Haab.length; i++) { if(Haab[i].equals(monthStr)) return i; } return -1; } }?