ZJANS

c636. 十二生肖

Easy Last Update: 2026/01/22

※ 沒有 0 年,民國前1年(-1) → 民國前元年(1)


解法一

✅ 完整代碼

評分結果(參考) : AC (2ms, 320KB)

#include<bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s[] = {"鼠", "牛", "虎", "兔", "龍", "蛇",
                  "馬", "羊", "猴", "雞", "狗", "豬"};
    
    int y;
    while(cin >> y){
        if(y < 0) cout << s[(y+120)%12] << "\n";
        else cout << s[(y-1)%12] << "\n";
    }
    
    return 0;
}