首页 > 代码库 > 算法:POJ1008 Maya Calendar
算法:POJ1008 Maya Calendar
此题非常水,不做说明。
package practice;import java.io.BufferedInputStream;import java.util.Scanner;/** * @author caiyu * @date 2014-12-2 */public class POJ1008 { static final String[] HaabMonth = new String[] { "pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet" }; static final String[] TzolkinMonth = new String[] { "imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau" }; /** * @param args */ public static void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); int t = cin.nextInt(); for (int i = 0; i < t; i++) { float d = cin.nextFloat(); String m = cin.next(); int y = cin.nextInt(); System.out.println(convert(d, m, y)); } } private static String convert(float d, String m, int y) { int md = 0; for (int i = 0; i < HaabMonth.length; i++) { if (HaabMonth[i].equals(m)) { md = i * 20; } } int days = y * 365 + (int) d + md; return days % 13 + 1 + " " + TzolkinMonth[days % 20] + " " + days / 260; }}
算法:POJ1008 Maya Calendar
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。