ACM (TJU) : 1002


#include <iostream>
using namespace std;

int haab_month (string month)
{
    if ( month == "pop" )
        return 0;

    if ( month == "no" )
        return 1;

    if ( month == "zip" )
        return 2;

    if ( month == "zotz" )
        return 3;

    if ( month == "tzec" )
        return 4;

    if ( month == "xul" )
        return 5;

    if ( month == "yoxkin" )
        return 6;

    if ( month == "mol" )
        return 7;

    if ( month == "chen" )
        return 8;

    if ( month == "yax" )
        return 9;

    if ( month == "zac" )
        return 10;

    if ( month == "ceh" )
        return 11;

    if ( month == "mac" )
        return 12;

    if ( month == "kankin" )
        return 13;

    if ( month == "muan" )
        return 14;

    if ( month == "pax" )
        return 15;

    if ( month == "koyab" )
        return 16;

    if ( month == "cumhu" )
        return 17;

    if ( month == "uayet" )
        return 18;

    return -1;
}

string tzolkin_month (int month)
{
    if ( month == 1 )
        return "imix";

    if ( month == 2 )
        return "ik";

    if ( month == 3 )
        return "akbal";

    if ( month == 4 )
        return "kan";

    if ( month == 5 )
        return "chicchan";

    if ( month == 6 )
        return "cimi";

    if ( month == 7 )
        return "manik";

    if ( month == 8 )
        return "lamat";

    if ( month == 9 )
        return "muluk";

    if ( month == 10 )
        return "ok";

    if ( month == 11 )
        return "chuen";

    if ( month == 12 )
        return "eb";

    if ( month == 13 )
        return "ben";

    if ( month == 14 )
        return "ix";

    if ( month == 15 )
        return "mem";

    if ( month == 16 )
        return "cib";

    if ( month == 17 )
        return "caban";

    if ( month == 18 )
        return "eznab";

    if ( month == 19 )
        return "canac";

    if ( month == 0 )
        return "ahau";

    return "";
}

int main ()
{
    int testCase;
    cin >> testCase;
    cout << testCase << endl;

    while ( testCase-- ) {

        int day;
        char dot;
        string month;
        int year;

        cin >> day >> dot >> month >> year;

        int total_days = 0;

        total_days += day; // days
        total_days++;

        int month_days = haab_month (month); // month
        total_days += ((month_days) * 20);

        for ( int i = 1; i <= year; i++ )
            total_days += 365;

        if ( total_days % 13 == 0 )
            cout << "13 ";
        else
            cout << total_days % 13 << " ";

        cout << tzolkin_month (total_days % 20) << " ";

        if ( total_days % 260 == 0 )
        cout << ( total_days / 260 ) - 1 << endl;
        else
        cout << total_days / 260 << endl;

    }

    return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s