Poj OpenJudge 百练 Bailian 1008 Maya Calendar

时间:2022-09-04 15:18:03

1.Link:

http://poj.org/problem?id=1008

http://bailian.openjudge.cn/practice/1008/

2.content:

Maya Calendar
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 66971   Accepted: 20644

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

3.Method:

简单题目,唯一要注意的是Haab历的日期是从0开始的,而tzolkin历是从1开始

4.Code:

 #include <iostream>
#include <string> using namespace std; const int haab_day_of_year = * + ;
const string name_of_month_haab[] = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol", "chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu","uayet"};
const int haab_num_of_month = ;
const int haab_day_of_month = ; const int tzolkin_day_of_year = * ;
const int tzolkin_day_of_num = ;
const int tzolkin_day_of_period = ;
const string name_of_num[] = {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat", "muluk", "ok", "chuen", "eb", "ben","ix", "mem", "cib", "caban", "eznab", "canac", "ahau"}; int get_haab_day(const int year,const string str_month,const int day)
{
int count = year * haab_day_of_year; int i = ;
for(i = ; i < haab_num_of_month; ++i) if(str_month == name_of_month_haab[i]) break;
count += i * haab_day_of_month + day; return count; } void get_tzolkin_date_of_count(const int count)
{
int year = count / tzolkin_day_of_year; int l_count = count % tzolkin_day_of_year; int num = l_count % tzolkin_day_of_num;
int period = l_count % tzolkin_day_of_period + ; cout << period << " " << name_of_num[num] << " " << year << endl; return; } int main()
{
//freopen("D://input.txt","r",stdin); int n;
cin >> n; cout << n << endl; while(n--)
{
int day = ;
string str_month = "";
int year = ; cin >> day;
cin.get();
cin >> str_month >> year; //cout << "year= " << year << endl;
//cout << "month= " << str_month << endl;
//cout << "day= " << day << endl; int count = get_haab_day(year,str_month,day); //cout << count << endl; get_tzolkin_date_of_count(count); } return ;
}

Poj OpenJudge 百练 Bailian 1008 Maya Calendar的更多相关文章

  1. Poj OpenJudge 百练 1062 昂贵的聘礼

    1.Link: http://poj.org/problem?id=1062 http://bailian.openjudge.cn/practice/1062/ 2.Content: 昂贵的聘礼 T ...

  2. Poj OpenJudge 百练 1860 Currency Exchang

    1.Link: http://poj.org/problem?id=1860 http://bailian.openjudge.cn/practice/1860 2.Content: Currency ...

  3. Poj OpenJudge 百练 2602 Superlong sums

    1.Link: http://poj.org/problem?id=2602 http://bailian.openjudge.cn/practice/2602/ 2.Content: Superlo ...

  4. Poj OpenJudge 百练 2389 Bull Math

    1.Link: http://poj.org/problem?id=2389 http://bailian.openjudge.cn/practice/2389/ 2.Content: Bull Ma ...

  5. Poj OpenJudge 百练 1573 Robot Motion

    1.Link: http://poj.org/problem?id=1573 http://bailian.openjudge.cn/practice/1573/ 2.Content: Robot M ...

  6. Poj OpenJudge 百练 2632 Crashing Robots

    1.Link: http://poj.org/problem?id=2632 http://bailian.openjudge.cn/practice/2632/ 2.Content: Crashin ...

  7. poj 1008&colon;Maya Calendar(模拟题,玛雅日历转换)

    Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64795   Accepted: 19978 D ...

  8. POJ 1008 Maya Calendar

    链接:http://poj.org/problem?id=1008 Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Subm ...

  9. &lbrack;POJ 1008&rsqb; Maya Calendar C&plus;&plus;解题

        Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 62297   Accepted: 192 ...

随机推荐

  1. hdu 5927 Auxiliary Set

    传送门 分析:感觉这道题有点意思.就写一篇mark一下吧. 现场比赛的时候去枚举了儿子用了线段树+dfs序,和预想的一样T了. 可以换一个想法,从儿子对父亲的贡献来思考. 在点中先假设一个节点的每一个 ...

  2. 【MySql】存储过程添加事务

    存储过程使用SQLException捕获SQL错误,然后处理: 我们可以在MySQL存储过程中捕获SQL错误,然后通过事务判断,回滚(ROLLBACK)还是提交(COMMIT). CREATE PRO ...

  3. Swift2&period;1 语法指南——析构过程

    原档:https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programmi ...

  4. azure存储压测的问题&lpar;农码主观意识太强被坑了&rpar;

    由于公司想把部份业务迁到windowsazure,主要是应用winodwsazure的存储;在方案中为了体现存储的可靠性所以对winodwsazure存储进行了一系列的测试.但在读取压力测试环节中发现 ...

  5. &lbrack;原&rsqb;零基础学习视频解码之android篇系列文章

    截止今天,<零基础学习视频解码系列文章>.<零基础学习在Android进行SDL开发系列文章>以及<零基础学习视频解码之android篇>系列文章基本算是告一段落了 ...

  6. linux 多台 主机的免登录ssh的配置

    1.首先检查 有没有安装ssh rpm-qa | grep ssh 如果没有安装 yum install ssh 2.在每一台机器上执行  ssh-keygen -t rsa  会在root/.ssh ...

  7. &lbrack;转&rsqb;NPOI TestFunctionRegistry&period;cs

    本文转自:https://github.com/tonyqus/npoi/blob/master/testcases/main/SS/Formula/TestFunctionRegistry.cs   ...

  8. JavaScript&sol;jQuery 表单美化插件小结

    Niceforms Niceforms是一款独立的表单美化工具,当前版本为2.0 官方主页:http://www.emblematiq.com/lab/niceforms/ 官方演示:http://w ...

  9. iOS里的crc校验问题

    首先推荐一篇文章,下面的的文章对crc解释的很好: https://blog.csdn.net/liyuanbhu/article/details/7882789 crc校验算法的本质就是对一个2进制 ...

  10. Jquery中bind&lpar;&rpar;&comma; live&lpar;&rpar;&comma; on&lpar;&rpar;&comma; delegate&lpar;&rpar;四种注册事件的优缺点,建议使用on()

    jquery中注册的事件,注册事件很容易理解偏差,叫法不一样.我第一反应就是如何添加事件,使用onclick之类的,暂时不讨论js注册事件的方法. 也看到园内前辈写过相关的帖子,但不是很详细,我找到了 ...