zoukankan      html  css  js  c++  java
  • POJ 1008 Maya Calendar

    Time Limit: 1000MS   Memory Limit: 10000K
    Total Submissions: 81591   Accepted: 25080

    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

    Source

    思路:模拟。
    #include<cstdio>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    int n;
    int m[1000];
    int main(){
        cin>>n;
        for(int i=1;i<=n;i++){
            int dd,mm,yy;char str[10];
            scanf("%d. %s %d",&dd,&str,&yy);
            string strs=str;
            if(strs.compare("pop")==0)    mm=0;
            else if(strs.compare("no")==0)    mm=1;
            else if(strs.compare("zip")==0)    mm=2;
            else if(strs.compare("zotz")==0)    mm=3;
            else if(strs.compare("tzec")==0)    mm=4;
            else if(strs.compare("xul")==0)    mm=5;
            else if(strs.compare("yoxkin")==0)    mm=6;
            else if(strs.compare("mol")==0)    mm=7;
            else if(strs.compare("chen")==0)    mm=8;
            else if(strs.compare("yax")==0)    mm=9;
            else if(strs.compare("zac")==0)    mm=10;
            else if(strs.compare("ceh")==0)    mm=11;
            else if(strs.compare("mac")==0)    mm=12;
            else if(strs.compare("kankin")==0)    mm=13;
            else if(strs.compare("muan")==0)    mm=14;
            else if(strs.compare("pax")==0)    mm=15;
            else if(strs.compare("koyab")==0)    mm=16;
            else if(strs.compare("cumhu")==0)    mm=17;
            else if(strs.compare("uayet")==0)    mm=18;
            m[i]=yy*365+mm*20+dd;
        }
        cout<<n<<endl;
        for(int i=1;i<=n;i++){
            cout<<m[i]%13+1<<" ";
            if(m[i]%20+1==1)    cout<<"imix ";
            else if(m[i]%20+1==2)    cout<<"ik ";
            else if(m[i]%20+1==3)    cout<<"akbal ";
            else if(m[i]%20+1==4)    cout<<"kan ";
            else if(m[i]%20+1==5)    cout<<"chicchan ";
            else if(m[i]%20+1==6)    cout<<"cimi ";
            else if(m[i]%20+1==7)    cout<<"manik ";
            else if(m[i]%20+1==8)    cout<<"lamat ";
            else if(m[i]%20+1==9)    cout<<"muluk ";
            else if(m[i]%20+1==10)    cout<<"ok ";
            else if(m[i]%20+1==11)    cout<<"chuen ";
            else if(m[i]%20+1==12)    cout<<"eb ";
            else if(m[i]%20+1==13)    cout<<"ben ";
            else if(m[i]%20+1==14)    cout<<"ix ";
            else if(m[i]%20+1==15)    cout<<"mem ";
            else if(m[i]%20+1==16)    cout<<"cib ";
            else if(m[i]%20+1==17)    cout<<"caban ";
            else if(m[i]%20+1==18)    cout<<"eznab ";
            else if(m[i]%20+1==19)    cout<<"canac ";
            else if(m[i]%20+1==20)    cout<<"ahau ";
            cout<<m[i]/260<<endl;
        }
    }
    细雨斜风作晓寒。淡烟疏柳媚晴滩。入淮清洛渐漫漫。 雪沫乳花浮午盏,蓼茸蒿笋试春盘。人间有味是清欢。
  • 相关阅读:
    VUE 多页面配置(二)
    VUE 多页面配置(一)
    VUE (vue-cli)脚手架项目说明
    CSS 三角形与圆形
    协同过滤算法之组合加权评分
    用户投票算法
    Android开发学习总结(一)——搭建最新版本的Android开发环境
    关于统计变换(CT/MCT/RMCT)算法的学习和实现
    SIFT 特征提取算法总结
    Android Listener侦听的N种写法
  • 原文地址:https://www.cnblogs.com/cangT-Tlan/p/8832578.html
Copyright © 2011-2022 走看看