【題解】ZeroJudge a003: 兩光法師占卜術

【題目敘述】https://zerojudge.tw/ShowProblem?problemid=a003

#include <iostream>
using namespace std;

int main()
{
    int M, D, S;
    cin >> M >> D;
    S = (M * 2 + D) % 3;
    if (S == 0) {
        cout << "普通\n";
    } else if (S == 1) {
        cout << "吉\n";
    } else {
        cout << "大吉\n";
    }
    return 0;
}

Python code (credit: Amy Chou)

M, D = map(int, input().split())

S = (M * 2 + D) % 3

if S == 0:
    print("普通")
elif S == 1:
    print("吉")
else:
    print("大吉")
分享本文 Share with friends