2012/02/12

[zerojudge] a003 兩光法師占卜術

題目:https://zerojudge.tw/ShowProblem?problemid=a003
說明:簡單數字的運算,讀取 stdin 後,用空白來拆開數字,運算後根據結果使用 ifelse 來印出對應內容。

Java 版
import java.util.Scanner;

public class A003 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String [] str;
        while (in.hasNext()) {
            str = in.nextLine().split(" ");
            int m = Integer.parseInt(str[0]);
            int d = Integer.parseInt(str[1]);
            int s = (m * 2 + d) % 3;

            if (s == 0)
                System.out.println("普通");
            else if (s == 1)
                System.out.println("吉");
            else
                System.out.println("大吉");
        }
    }
}
Python 版 (2022.06)
m, d = (input().split())
m = int(m)
d = int(d)
s = (m * 2 + d) % 3
if s == 0:
    print('普通')
elif s == 1:
    print('吉')
else:
    print('大吉')

沒有留言:

張貼留言