zoukankan      html  css  js  c++  java
  • POJ 1008 简单模拟题

    e.... 虽然这是一道灰常简单的模拟题、但是米做的时候没有读懂第二个日历的计时方法。然后捏。敲完之后华丽的WA了进一个点。坑点就在一年的最后一天你是该输出本年的。e ...但是我好想并没有。、看discuss里好想被坑的人还不少。总天数能直接整除260的时候。年数要减1。

    不喜欢做模拟.....5555....

    附代码:

    #include<stdio.h>
    #include<string.h>
    #include<iostream>
    #include<string>
    #include<map>
    using namespace std;


    string Maya_name[20] = {"pop", "no", "zip", "zotz", "tzec",  "xul", "yoxkin", "mol", "chen", "yax",  "zac", "ceh", "mac", "kankin", "muan",  "pax", "koyab", "cumhu", "uayet"};
    string Holly_name[21] = {"imix", "ik", "akbal", "kan", "chicchan",   "cimi", "manik", "lamat", "muluk", "ok",   "chuen", "eb", "ben", "ix", "mem",   "cib", "caban", "eznab", "canac", "ahau"};

    int main()
    {
        map<string, int>m;
        m.clear();
        for (int i=0; i<19; ++i)
        {
            m[Maya_name[i]] = i;
        }

        map<int, string>mm;
        mm.clear();
        for (int i=0; i<20; ++i)
        {
            mm[i+1] = Holly_name[i];
        }

        int t, total;
        int day, year;
        char temp;
        string month;
        while(cin >> t)
        {
            cout << t << endl;
            while(t--)
            {
                total = 0;
                cin >> day >> temp >> month >> year;
                int tm = m[month];
                total += year * 365 + tm * 20 + day + 1;
               // cout << total << "== ";
                year = total / 260;
                int tot = total;
                tot %= 260;
                tm = tot % 20;
                if (tm == 0) tm = 20;
                day = total % 13;
                if (day == 0) day = 13;
                if (total % 260 == 0)
                {
                    year -= 1;
                }
                cout << day << ' ' << mm[tm] << ' ' << year << endl;
            }
        }
        return 0;
    }


  • 相关阅读:
    C++多态深入分析!
    字符编码总结
    算法:并查集
    树的非递归遍历:一种很好的算法
    算法:快速排序
    算法:堆排序
    字符串匹配:KMP算法, Boyer-Moore算法理解与总结
    shodan搜索
    google hacking 语法
    FOFA的搜索语句
  • 原文地址:https://www.cnblogs.com/icode-girl/p/4600776.html
Copyright © 2011-2022 走看看