#MTHA0000011. Số có số dư cho trước (Numbers with a Given Remainder)
Số có số dư cho trước (Numbers with a Given Remainder)
Numbers with a Given Remainder
Version: Phuoc Hung OJ Extended
Problem Statement
Given integers with and , count the integers in such that .
Input
One line contains four integers , , , and .
Output
Print the number of integers satisfying the condition.
Subtasks
- Subtask 1 (30 points):
- .
- .
- .
- Subtask 2 (70 points):
- .
- .
- .
Examples
Example 1
Input
1 20 5 2
Output
4
Explanation
The integers with remainder modulo are , so the answer is .
Example 2
Input
1 20 5 0
Output
4
Explanation
Remainder corresponds to multiples , giving integers.
Example 3
Input
8 8 10 8
Output
1
Explanation
The interval contains only , and , so exactly one integer is valid.