PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000292. Bài toán lựa chọn quà (Gift Dilemma)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Bài toán lựa chọn quà (Gift Dilemma)
Gift Dilemma
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Sheldon wants to purchase gifts whose total cost is exactly . A shop offers three kinds of goods: Rubik’s cubes, harmonicas, and chocolates, costing respectively. Let denote the quantities of each kind. Every quantity must be a nonnegative integer. Count all distinct triples satisfying . Each different triple counts as one way, including triples with zero quantities.
Input
One line containing four integers in that order.
Output
Print one integer: the number of nonnegative integer triples satisfying the equation.
Subtasks
- Subtask 1 (20 points): , , .
- Subtask 2 (30 points): , , .
- Subtask 3 (50 points): , , .
Examples
Example 1
Input
202 203 200 606
Output
2
Explanation
There are exactly two choices: gives , and gives .