Định nghĩa lớp abstract Operation có method abstract int Apply(int a, int b). Lớp Add kế thừa Operation override Apply trả về a+b. Lớp Mul kế thừa Operation override Apply trả về a*b. Đọc 3 token: op (add|mul), a, b. Tạo Operation tương ứng, gọi Apply, in kết quả.
Một dòng: op a b.
op ∈ {add, mul}; -10^4 <= a,b <= 10^4.
Một dòng: kết quả.
Ví dụ:
Đầu vào:
add 3 4
Đầu ra:
7
Giải thích:
Đang tải editor...