1100 Mars Numbers (20分)

 

#include<vector>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#define maxn 13

using namespace std;
string one[maxn] = {"tret", "jan", "feb", "mar", "apr", "may",
                    "jun", "jly", "aug", "sep", "oct", "nov", "dec"},
        ten[maxn] = {"tret", "tam", "hel", "maa", "huh", "tou",
                    "kes", "hei", "elo", "syy", "lok", "mer", "jou"};

int main() {
    int N;
    cin >> N;
    getchar();
    while(N--) {
        string a, b;
        int n;
        getline(cin, a);
        if (a[0] >= '0' && a[0] <= '9') {
            sscanf(a.c_str(), "%d", &n);
            if (n >= 13 && n % 13 != 0) {
                cout << ten[n / 13] << ' ' << one[n % 13] << endl;
            }
            else if (n >= 13) cout << ten[n / 13] << endl;
            else cout << one[n] << endl;
        }
        else {
            int i = 0;
            if (a.size() < 5) {
                for (i = 0; i < 13; i++) {
                    if (one[i] == a) break;
                }
                n = i;
                if (i == 13) {
                    for (i = 0; i < 13; i++) {
                        if (ten[i] == a) break;
                    }
                    n = i * 13;
                }
                cout << n << endl;
            }
            else {
                b = a.substr(0, 3);
                for (i = 0; i < 13; i++) {
                    if (ten[i] == b) break;
                }
                int j = 0;
                if (a.size() > 5) {
                    b = a.substr(4, 3);
                    for (j = 0; j < 13; j++) {
                        if (one[j] == b) break;
                    }
                }
                cout << i * 13 + j << endl;
            }
        }
    }

    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值