POJ:1008 JAVA
来源:互联网 发布:美团数据采集 编辑:程序博客网 时间:2024/06/06 19:36
Maya Calendar
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 78449 Accepted: 24123
Description
During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message, professor discovered that the Maya civilization used a 365 day long year, called Haab, which had 19 months. Each of the first 18 months was 20 days long, and the names of the months were pop, no, zip, zotz, tzec, xul, yoxkin, mol, chen, yax, zac, ceh, mac, kankin, muan, pax, koyab, cumhu. Instead of having names, the days of the months were denoted by numbers starting from 0 to 19. The last month of Haab was called uayet and had 5 days denoted by numbers 0, 1, 2, 3, 4. The Maya believed that this month was unlucky, the court of justice was not in session, the trade stopped, people did not even sweep the floor.
For religious purposes, the Maya used another calendar in which the year was called Tzolkin (holly year). The year was divided into thirteen periods, each 20 days long. Each day was denoted by a pair consisting of a number and the name of the day. They used 20 names: imix, ik, akbal, kan, chicchan, cimi, manik, lamat, muluk, ok, chuen, eb, ben, ix, mem, cib, caban, eznab, canac, ahau and 13 numbers; both in cycles.
Notice that each day has an unambiguous description. For example, at the beginning of the year the days were described as follows:
1 imix, 2 ik, 3 akbal, 4 kan, 5 chicchan, 6 cimi, 7 manik, 8 lamat, 9 muluk, 10 ok, 11 chuen, 12 eb, 13 ben, 1 ix, 2 mem, 3 cib, 4 caban, 5 eznab, 6 canac, 7 ahau, and again in the next period 8 imix, 9 ik, 10 akbal …
Years (both Haab and Tzolkin) were denoted by numbers 0, 1, : : : , where the number 0 was the beginning of the world. Thus, the first day was:
Haab: 0. pop 0
Tzolkin: 1 imix 0
Help professor M. A. Ya and write a program for him to convert the dates from the Haab calendar to the Tzolkin calendar.
Input
The date in Haab is given in the following format:
NumberOfTheDay. Month Year
The first line of the input file contains the number of the input dates in the file. The next n lines contain n dates in the Haab calendar format, each in separate line. The year is smaller then 5000.
Output
The date in Tzolkin should be in the following format:
Number NameOfTheDay Year
The first line of the output file contains the number of the output dates. In the next n lines, there are dates in the Tzolkin calendar format, in the order corresponding to the input dates.
Sample Input
3
10. zac 0
0. pop 0
10. zac 1995
Sample Output
3
3 chuen 0
1 imix 0
9 cimi 2801
代码:
import java.util.HashMap;import java.util.Map;import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); Map<String, Integer> Haab = new HashMap<String, Integer>(); Haab.put("pop", 1); Haab.put("no", 2); Haab.put("zip", 3); Haab.put("zotz", 4); Haab.put("tzec", 5); Haab.put("xul", 6); Haab.put("yoxkin", 7); Haab.put("mol", 8); Haab.put("chen", 9); Haab.put("yax", 10); Haab.put("zac", 11); Haab.put("ceh", 12); Haab.put("mac", 13); Haab.put("kankin", 14); Haab.put("muan", 15); Haab.put("pax", 16); Haab.put("koyab", 17); Haab.put("cumhu", 18); Haab.put("uayet", 19); Map<Integer, String> Tzol = new HashMap<Integer, String>(); Tzol.put(1, "imix"); Tzol.put(2, "ik"); Tzol.put(3, "akbal"); Tzol.put(4, "kan"); Tzol.put(5, "chicchan"); Tzol.put(6, "cimi"); Tzol.put(7, "manik"); Tzol.put(8, "lamat"); Tzol.put(9, "muluk"); Tzol.put(10, "ok"); Tzol.put(11, "chuen"); Tzol.put(12, "eb"); Tzol.put(13, "ben"); Tzol.put(14, "ix"); Tzol.put(15, "mem"); Tzol.put(16, "cib"); Tzol.put(17, "caban"); Tzol.put(18, "eznab"); Tzol.put(19, "canac"); Tzol.put(20, "ahau"); if (scanner.hasNext()) { int n = scanner.nextInt(); System.out.println(n); for (int i = 0; i < n; i++) { int day = Integer.parseInt(scanner.next().replace(".", "")); int month = Haab.get(scanner.next()); int year = scanner.nextInt(); int tmpday = 365 * year + 20 * (month - 1) + day + 1; // 当刚好为260天时,其实是第0年最后一天,这里做-1操作,避免这个问题,同时对其它年份也不会有影响。 int T_year = (tmpday-1) / 260; int T_month_N = (tmpday % 260) % 13; if (T_month_N == 0) { T_month_N = 13; } int T_month_S = (tmpday % 260) % 20; if (T_month_S == 0) { System.out.println(T_month_N + " " + Tzol.get(20) + " " + T_year); } else { System.out.println(T_month_N + " " + Tzol.get(T_month_S) + " " + T_year); } } } scanner.close(); }}
- poj 1008 Java
- POJ:1008 JAVA
- POJ 1008 Maya Calendar [解题报告] Java
- POJ 2418 Java
- POJ 2299 Java
- POJ 1011 - Java
- poj 1032 java版本
- poj 2389 Java
- poj 1002 Java
- poj 1003 Java
- poj 1004 Java
- poj 1005 Java
- poj 1007 Java
- poj 3274 java
- poj 2706 java
- poj 3308 java
- poj 2195 java
- poj 2528 java
- python进行数据分析 chapter 2-1
- 云和恩墨大讲堂 | 基于PCIE 闪存卡的 Oracle 数据库使用
- MyBatis开发环境搭建
- Invenio安装步骤(一)
- IntelliJ IDEA中Push failed: Failed with error: unable to access xx:Unknown SSL protocol error in
- POJ:1008 JAVA
- 创建可传递的林信任,Active Directory系列之二十
- 安卓edText编辑框禁止输入表情符号,使用正则表达式
- MySQL双机热备简介实现(Windows+liunx)+liunx下MySQL数据库日常数据备份
- JS跨域问题
- WEBBASIC Unit03 CSS声明
- LVS NAT模式
- Web.Config错误页配置
- EL表达式、Servle