Poj OpenJudge 百练 Bailian 1008 Maya Calendar
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 YearThe 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 YearThe 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 1995Sample Output
3
3 chuen 0
1 imix 0
9 cimi 2801Source
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的更多相关文章
- Poj OpenJudge 百练 1062 昂贵的聘礼
1.Link: http://poj.org/problem?id=1062 http://bailian.openjudge.cn/practice/1062/ 2.Content: 昂贵的聘礼 T ...
- Poj OpenJudge 百练 1860 Currency Exchang
1.Link: http://poj.org/problem?id=1860 http://bailian.openjudge.cn/practice/1860 2.Content: Currency ...
- Poj OpenJudge 百练 2602 Superlong sums
1.Link: http://poj.org/problem?id=2602 http://bailian.openjudge.cn/practice/2602/ 2.Content: Superlo ...
- Poj OpenJudge 百练 2389 Bull Math
1.Link: http://poj.org/problem?id=2389 http://bailian.openjudge.cn/practice/2389/ 2.Content: Bull Ma ...
- Poj OpenJudge 百练 1573 Robot Motion
1.Link: http://poj.org/problem?id=1573 http://bailian.openjudge.cn/practice/1573/ 2.Content: Robot M ...
- Poj OpenJudge 百练 2632 Crashing Robots
1.Link: http://poj.org/problem?id=2632 http://bailian.openjudge.cn/practice/2632/ 2.Content: Crashin ...
- poj 1008:Maya Calendar(模拟题,玛雅日历转换)
Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 64795 Accepted: 19978 D ...
- POJ 1008 Maya Calendar
链接:http://poj.org/problem?id=1008 Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Subm ...
- [POJ 1008] Maya Calendar C++解题
Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 62297 Accepted: 192 ...
随机推荐
- Android监听SD卡文件变化
今天再一次使用到FileObserver,上一次使用还是很久之前了.总结一下FileObserver里留的一些“坑” 1.FileObserver只能监听一个目录下的“一级”子文件,也就是说Fil ...
- MongoDB 主从复制小实验
MongoDB 主从复制小实验 操作环境描述:WIN8 64位操作系统,内装虚拟机为CentOS 5.5 32位系统. 操作描述:跟其他关系型数据库类似,在主库进行数据操作,将数据同步到从节点,从节 ...
- pager 命令
https://www.percona.com/blog/2013/01/21/fun-with-the-mysql-pager-command/ Last time I wrote about a ...
- F5 负载均衡
http://xjsunjie.blog.51cto.com/blog/999372/697285 http://www.eimhe.com/thread-142659-1-1.html
- Python学习 之 运算符&表达式
1.Python运算符包括:赋值运算符.算术运算符.关系运算符.逻辑运算符. 表达式是将不同的数据(包括变量.函数)用运算符号按一定规则连接起来的一种式子. 2.赋值运算符:=.+=.-=.*=./= ...
- 文件尾存在EOF吗?
参考:http://bbs.csdn.net/topics/290027166 我們先一起來看看FILE是怎么定義的: FILE <STDI ...
- 小白日记19:kali渗透测试之选择和修改EXP
EXP 目的:学会选择和修改网上公开的漏洞利用代码[EXP(python\perl\ruby\c\c++....)] 方法: 1.Exploit-db[kali官方维护的漏洞利用代码库] 2.Secu ...
- iOS H5容器的一些探究(一):UIWebView和WKWebView的比较和选择
一.Native开发中为什么需要H5容器 Native开发原生应用是手机操作系统厂商(目前主要是苹果的iOS和google的Android)对外界提供的标准化的开发模式,他们对于native开发提供了 ...
- BootStrap2学习日记1--网格系统
在BoootStrap2的版本中采用的布局方式是12栏网格布局(把浏览器的Width分12栏,布局中使用每个元素所占格数的不同来达到各种布局),包括(固定)网格布局(Grid System)和流式网格 ...
- Columbus’s bargain
Columbus’s bargain Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...