模拟日历计算 poj1008

Maya Calendar

Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 69932   Accepted: 21524

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

题意:看了我近半小时Orz 英语太弱了

玛雅人有两种纪年:haab 和 holly

haab : 365天

19个月 最后一个uayet月 只有5天

holly

260天

13个月

每月都是20天

总的天数sum%13+1 为日期

sum%20+1 为月份

sum/260为年份
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

int init_Haab(char *s)
{
    if(strcmp(s,"pop")==0)
        return 1;
    else if(strcmp(s,"no")==0)
        return 2;
    else if(strcmp(s,"zip")==0)
        return 3;
    else if(strcmp(s,"zotz")==0)
        return 4;
    else if(strcmp(s,"tzec")==0)
        return 5;
    else if(strcmp(s,"xul")==0)
        return 6;
    else if(strcmp(s,"yoxkin")==0)
        return 7;
    else if(strcmp(s,"mol")==0)
        return 8;
    else if(strcmp(s,"chen")==0)
        return 9;
    else if(strcmp(s,"yax")==0)
        return 10;
    else if(strcmp(s,"zac")==0)
        return 11;
    else if(strcmp(s,"ceh")==0)
        return 12;
    else if(strcmp(s,"mac")==0)
        return 13;
    else if(strcmp(s,"kankin")==0)
        return 14;
    else if(strcmp(s,"muan")==0)
        return 15;
    else if(strcmp(s,"pax")==0)
        return 16;
    else if(strcmp(s,"koyab")==0)
        return 17;
    else if(strcmp(s,"cumhu")==0)
        return 18;
    else if(strcmp(s,"uayet")==0)
        return 19;
}

int sumday(int d,int m,int y)
{
    int sum=0;
    for(int i=1;i<=y;i++)
        sum+=365;
    for(int i=1;i<m;i++)//千万注意
        sum+=20;
    return sum+d;
}
// imix, ik, akbal, kan, chicchan, cimi, manik, lamat, muluk, ok, chuen, eb, ben, ix, mem, cib, caban, eznab, canac, ahau
char str[25][10]={"0","imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
int main()
{
    int t;
    scanf("%d",&t);
    printf("%d\n",t);
    while(t--)
    {
        int d,y;
        char s[10];
        scanf("%d. %s %d",&d,s,&y);

        int sum = sumday(d,init_Haab(s),y);
        int hd=sum%13+1;
        int hm=sum%20+1;
        int hy=sum/260;

        printf("%d %s %d\n",hd,str[hm],hy);
    }
}

时间: 2024-07-30 15:25:18

模拟日历计算 poj1008的相关文章

5分钟模拟“透明计算”

本课程为本人参加实验楼项目课大赛5分钟模拟"透明计算"课程文档,若需转载请注明出处 透明计算相信大家都听说过,不知道的可自行百度.本实验课是一个科普实验,实验中可以学习到虚拟机及远程桌面基本概念,并自己动手搭建一个模拟透明计算的教学演示环境. 注意事项 本课只是模拟透明计算的演示效果,形似而已,绝非实现透明计算,毕竟我并不清楚透明计算的具体的技术原理.实验中选用的技术只是用来快速搭建一个通过浏览器访问的远程桌面,与透明计算没有任何关联. 5分钟是敲命令和环境配置的时间,不含文档阅读时间

08:特殊日历计算

08:特殊日历计算总时间限制:1000ms 内存限制:65536kB描述    有一种特殊的日历法,它的一天和我们现在用的日历法的一天是一样长的.    它每天有10个小时,每个小时有100分钟,每分钟有100秒.    10天算一周,10周算一个月,10个月算一年.    现在要你编写一个程序,将我们常用的日历法的日期转换成这种特殊的日历表示法.    这种日历法的时.分.秒是从0开始计数的.日.月从1开始计数,年从0开始计数.秒数为整数. 假设 0:0:0 1.1.2000 等同于特殊日历法

11.3.3 用函数模拟延迟计算

在F# 和C# 中计算顺序是提前的:作为给函数参数使用的表达式,在函数自身开始执行之前就计算好了.在C# 和F# 中,我们可以使用函数值模拟延迟计算,另外,F# 甚至有一个专门的关键字,支持延迟计算. 但首先,对于提前计算规则有一个例外,你肯定知道,并经常使用,但只是因为太常用,反而可能没有意识到它的特别.有些特定的C# 运算符,比如,逻辑或(||).逻辑与(&&).条件运算符(?:),以及空合并运算符(null-coalescing,??),能实现短路径(short-circuiting

javascript 模拟日历

1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6 <style> 7 div { 8 width: 800px; 9 margin: 200px auto; 10 color: orange; 11 text-align: center;

PAT甲题题解-1088. Rational Arithmetic (20)-模拟分数计算

输入为两个分数,让你计算+,-,*,\四种结果,并且输出对应的式子,分数要按带分数的格式k a/b输出如果为负数,则带分数两边要有括号如果除数为0,则式子中的结果输出Inf模拟题最好自己动手实现,考验细节处理,其它没啥好说的. #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; long long numerato

PAT甲题题解-1081. Rational Sum (20)-模拟分数计算

模拟计算一些分数的和,结果以带分数的形式输出注意一些细节即可 #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; /* 模拟计算一些分数的和,结果以带分数的形式输出 注意一些细节即可 */ const int maxn=105; const int maxv=50000

[C语言]模拟人工计算CRC校验码

组成原理课程设计要实现CRC码的生成与校验,然而并不会用硬件实现... 只好先用C写着玩玩,做题还能用上...网原要考的... 例题:要发送的数据为1101011011,CRC生成多项式P(X)=X4+X+1,求应添加在数据后面的余数. 笔算过程: 编程算: 附上小白的代码... 1 #include "stdafx.h" 2 #define DATABIT_LENGTH 10 //数据位数 3 #define GENERATOR_LENGTH 5 //生成多项式位数 4 #defin

大数计算问题

在求阶乘问题上,我们可以使用循环或者递归的思想,如果数值范围超过基本数据类型,可以使用java中的BigDecimal和BigInteger类:但是如果不使用java中这两个类怎么来计算呢? 拿两个数相乘来说,思路在于观察我们如何手工计算相乘,用程序来模拟手工计算相乘即可 1 import java.util.Scanner; 2 3 /** 4 * 大数相乘问题 5 * @author zbt 6 * 7 */ 8 public class MyBigData { 9 10 public st

Sulphur.eXperts.Sulsim.V7.0 硫磺回收模拟软件

Sulphur.eXperts.Sulsim.V7.0 硫磺回收模拟软件    Sulsim是Sulphur Experts公司全流程硫回收模拟软件.交互式的设定功能允许我们在软件所支持的过 程中增加或删除操作单元,通常这些过程包括改进克劳斯过程.亚露点克劳斯过程.选择性氧化以及多种 尾气处理过程.然后我们所确定的脱硫流程就能够以图形的方式显示在屏幕上.这种高度的灵活性使得我 们能很好的模拟与气体处理厂和炼厂相关联的所有的硫回收过程.QQ:16264558      TEL:1396378227