POJ 1008 Maya Calendar(模拟)

#include"cstdio"
#include"iostream"
#include"cstring"
using namespace std;
char H[19][10]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char T[20][10]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};
long get_h(int year,int day,char x[])
{   long ans=0;
    ans+=year*365;
    for(int i=0;i<19;i++)
        if(!strcmp(x,H[i])) {ans+=i*20;break;}
    ans+=day;
    cout<<ans<<‘a‘<<endl;
    return ans;
}
void get_t(long temp)
{   long year,num,name;
    year=temp/260;
    temp%=260;
    name=temp%20;
    num=temp%13+1;
    printf("%ld %s %ld\n",num,T[name],year);
}
int main()
{   int day,year,T;
    char x[10];
    scanf("%d",&T);
    cout<<T<<endl;
    while(T--)
    {   long temp;
        scanf("%d. %s %d",&day,x,&year);
        temp=get_h(year,day,x);
        get_t(temp);
    }
    return 0;
}

两种玛雅日期的转换,理解了题意并按照要求做就不会出错。有个需要注意的地方就是“uayet”这个月份容易被漏掉~~

时间: 2024-10-13 14:24:41

POJ 1008 Maya Calendar(模拟)的相关文章

poj 1008:Maya Calendar(模拟题,玛雅日历转换)

Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64795   Accepted: 19978 Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message, profes

[POJ] #1008# Maya Calendar : 字符处理/同余问题

一. 题目 Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 74085   Accepted: 22819 Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message,

POJ 1008 Maya Calendar 水模拟

有中文意思. 注意HOLLY法月份和天数是一起滚动的= = 要输出总组数,坑哭 #include <cstring> #include <cstdio> #include <algorithm> #include <map> #include <string> #include<iostream> using namespace std; map<string, int>f; const int N = 22; char

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

[POJ] POJ1008 Maya Calendar

该篇作为POJ之路的起点,初学乍道,请多指教. Problem: Maya Calendar 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

Poj Maya Calendar

http://poj.org/problem?id=1008 Maya Calendar Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 64607 Accepted: 19908 Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an

poj 3399 Product(模拟)

# include <stdio.h> # include <string.h> # include <algorithm> using namespace std; int cmp(int x,int y) { return x>y; } int main() { int a[110],a1[110],a2[110],ans[110]; int n,k,k1,k2,i,k3; while(~scanf("%d%d",&n,&k

POJ-1008 Maya Calendar

[题目描述] 将Haab历法的日期转化为Tzolkin历法,前者一年365天,后者一年260天.(简直比我们的历法转换还简单,都没闰年!) [思路分析] 简单的思路就是将Haab历法的日期转换成从第一天开始的总天数,再转换成Tzolkin历法.由于最大年份为5000年,乘上365天也不会使int型越界,所以放心转吧. 做题过程中主要复习的知识点是: 1. STL中map的用法: map<string, int> HaabMonth; // 定义 HaabMonth.insert( pair&l

poj 2632 Crashing Robots, 模拟

点击打开链接 简单 模拟机器人的移动,发生碰撞时输出相应的信息. code #include <cstdio> #include <cstring> using namespace std; struct node{ int k; int s; } mtx[200][200]; struct node1{ int x, y; } rob[200]; int n, m; int dir[4][2]= {{0,1},{1,0},{0,-1},{-1,0}}; //N, E, S, W