码迷,mamicode.com
首页 > 编程语言 > 详细

算法:POJ1008 Maya Calendar

时间:2014-12-02 16:35:39      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   ar   color   sp   java   for   on   

此题非常水,不做说明。

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

标签:style   blog   io   ar   color   sp   java   for   on   

原文地址:http://www.cnblogs.com/anrainie/p/4137805.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!