算法:POJ1008 Maya Calendar-阿里云开发者社区

开发者社区> 人工智能> 正文

算法:POJ1008 Maya Calendar

简介: 此题非常水,不做说明。 package practice; import java.io.BufferedInputStream; import java.util.Scanner; /** * @author caiyu * @date 2014-12-2 */ ...

此题非常水,不做说明。

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;
    }
}

 

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

分享:
人工智能
使用钉钉扫一扫加入圈子
+ 订阅

了解行业+人工智能最先进的技术和实践,参与行业+人工智能实践项目

其他文章