PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000286. Đếm nghiệm của Ai + Bj + Ck = X (Ai + Bj + Ck = X)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm nghiệm của Ai + Bj + Ck = X (Ai + Bj + Ck = X)
Ai + Bj + Ck = X
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given five positive integers , count the ordered triples of integers satisfying and . Two triples differing in at least one position are distinct.
Input
One line contains five integers , in this order.
Output
Print one integer: the number of qualifying triples .
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
5 3 1 5 15
Output
3
Explanation
For , precisely , and satisfy the equation.
Input
1 1 1 1 1
Output
0
Explanation
When , the only possible triple has weighted sum , not ; the answer is zero.
Input
100000 31415 92653 58979 1000000000
Output
2896
Explanation
For , there are qualifying triples, obtained by counting bounded solutions for each first coordinate .