zoukankan      html  css  js  c++  java
  • POJ1008

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

    这题没什么的,先算出总的天数,再算出另一种日历的表示就是了,没什么技巧可言。

    需要注意的是一个特殊的数据:

    4. uayet 259 ,应输出13 ahau 364

    基本上样例过了,再把上面的特殊数据过了就行了。

    #include <iostream>
    #include <cstdio>
    #include <string>
    #include <cstring>
    
    using namespace std;
    
    const char hmonth[19][10] = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol",
            "chen", "yax", "zac", "ceh", "mac", "kankin", "muan",
            "pax", "koyab", "cumhu", "uayet"};
    
    const string tday[20] = { "imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat",
                        "muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib",
                         "caban", "eznab", "canac", "ahau" };
    
    int find(char *month)
    {
        for (int i=0; i<20; i++)
            if (!strcmp(month, hmonth[i]))
            return i;
    }
    
    
    int main()
    {
        int ncase;
        cin>>ncase;
        cout<<ncase<<endl;
    
        int day, year;
        char ch;
        char month[10];
    
        for (int i=0; i<ncase; i++)
        {
            scanf("%d. %s%d", &day, &month, &year);
            int imonth = find(month);
            int sumday = year*365 + imonth*20 + day+1;
            int tyear = (sumday-1) / 260;   //这里要-1,不然/运算有可能出错
            sumday -= tyear*260;
            int ttday = sumday - (sumday / 13)*13;
                if (ttday == 0) ttday = 13;
            int tmonth = sumday - (sumday / 20) * 20;
            if (tmonth == 0) tmonth = 20;
            cout<<ttday<<" "<<tday[tmonth-1]<<" "<<tyear<<endl;
        }
        return 0;
    }
  • 相关阅读:
    information_schema
    面包屑路径导航
    mysql5.7.26安装
    菜单权限作为父权限
    权限控制到按钮
    二级菜单
    留言板和jq轮播图
    M商城
    表单
    w3c
  • 原文地址:https://www.cnblogs.com/ay27/p/2924012.html
Copyright © 2011-2022 走看看