PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000294. Giá trị nhỏ nhất của biểu thức dư tuyến tính (Min of Mod of Linear)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Giá trị nhỏ nhất của biểu thức dư tuyến tính (Min of Mod of Linear)
Min of Mod of Linear
Source: Library Checker
Version: Phuoc Hung OJ Extended
Problem Statement
Given four integers , consider the least nonnegative residues of modulo for all integer indices . Find the minimum of these residues. Every remainder is defined to lie in .
Input
One line containing four integers .
Output
Print one integer equal to .
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Example 1
Input
5 7 3 2
Output
0
Explanation
For the residues are 2, 5, 1, 4, 0. Their minimum is 0.
Example 2
Input
4 9 0 5
Output
5
Explanation
For the residues are 5, 5, 5, 5. Their minimum is 5.
Example 3
Input
6 10 4 1
Output
1
Explanation
For the residues are 1, 5, 9, 3, 7, 1. Their minimum is 1.