编程介的小学生 2019-08-28 21:47 采纳率: 20.5%
浏览 98

Mayan Dates 程序编写过程

Description

Background
The NASA has secretly built a Time machine which allows them to travel into the past. Its first application is to explore the Mayan culture. They have been able to gather some important dates from Maya monuments which are suitable for further investigation. They are now faced with a problem - they need to convert those Mayan dates to the Gregorian format, which is the only kind of input their time machine understands.
Problem
Write a conversion program to calculate the Gregorian date, the Mayan longcount and the Mayan ritual date for a given Gregorian date or Mayan longcount.

Mayan Longcount
The starting date, day zero, for the Mayan calendar is the 13th of August 3114 BC (before Christ). From this day zero onwards the days to a certain date are counted. One day is called K'in, 20 K'in are a Winal.18 Winal are a Tun, 20 Tun make a K'atun and 20 K'atun will form a Bak'tun. Example: 12.4.9.13.3 tells us that 12 Bak'tun, 4 K'atun, 9 Tun, 13 Winal and 3 K'in (days) have passed since August 13th 3114 BC.

Mayan Ritual Dates
The Mayans had the solar year with 365 days, there were no leap days to correct the calendar. The year was split in 18 month with 20 days and one month with 5 days. The names of the months are the following:Pob,Wo, Sip, Sotz', Tzek, Xul, Yaxk'in, Mol, Ch'en, Yax, Sak, Keh, Mak, K'ank'in, Muwan, Pax, K'ayab,Kumk'u, Wayeb. The days of the month were numbered 1 to 19 (or 1 to 4), the last day of the month was noted as day zero of the following month (i.e. you would not write 20 Pop, but 0 Wo to note the last day of the first month, the same applies to the five day month called Wayeb, its last day 5 Wayeb is written 0 Pop).Additionally to the months and days notation there is a notation which could be compared to our weeks and weekdays. Every day is labelled by both a number in the range from 1 to 13 and one of the following 20 names: Imix, Ik', Ak'bal, K'an, Chikchan, Kimi, Manik', Lamat, Muluk, Ok, Chuwen, Eb, Ben, Ix, Men,Kib, Kaban, Etz'nab, Kawak, Ahaw. Both the numbers and the names are running in cycles, so the count will go: 1 Imix, 2 Ik', 3 Ak'bal, ... 13 Ben, 1 Ix, 2 Men. It will thus take a 260 day cycle (called the ritual year) until 1 Imix is counted again (compare Figure 1 on next page).
The weekday and month notation are used together as in the following example: 2 Kimi (weekday) 10 Yax (day and month). The 13th of August 3114 BC has the ritual date 4 Ahaw 8 Kumk'u.

Gregorian Dates
In our calendar we use leap days. A leap day is inserted every 4 years, except every 100 years. Overruling this a leap day will be inserted every 400 years.
It is also important to know that there is no year 0. Accordingly, 31th of December 1 BC is followed by 1st of January AD 1. The last leap year before Christ is 1 BC (the 400 year rule applies here), the next leap year after that is AD 4.
Input

The first line contains the number of scenarios.
For each scenario, there is one line containing either a Mayan longcount or a Gregorian date in the following formats:
A Mayan longcount consists of 5 non-negative integers separated by dots.
A Gregorian date consists first of three integers d, m, and y, separated by slashes, and satisfying 1 <= d <= 31, 1 <= m <= 12, and 0 < y. The values may or may not be zero padded, but will never exceed two characters for d and m, and four for y. This representation is always followed by a single blank and either "BC" or "AD".

We will neither ask for dates preceding August 13th 3114 BC, nor for dates after 13.0.0.0.0 which is the last day in the Mayan longcount calendar. Also, you will never be given invalid dates in either calendar.
Output

The output for every scenario begins with a line containing "Scenario #i:", where i is the number of the scenario starting at 1. Then, regardless of the format given in the input, three lines have to be printed representing the given date in the following order:
1. the Gregorian date in the same format as specified in the input description, but without any padding zeros;
2. the Mayan longcount representation of the date, also as described before;
3. the Mayan ritual date consisting of four parts separated by single blanks: the weekday notation with its number and name, then the day of the month followed by the name of the month.
After these three lines, always a blank line must be printed.
Sample Input

2
13/08/3114 BC
12.19.10.6.14
Sample Output

Scenario #1:
13/8/3114 BC
0.0.0.0.0
4 Ahaw 8 Kumk'u

Scenario #2:
28/6/2003 AD
12.19.10.6.14
9 Ix 2 Tzek

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
    • ¥20 matlab yalmip kkt 双层优化问题
    • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
    • ¥88 实在没有想法,需要个思路
    • ¥15 MATLAB报错输入参数太多