PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000273. Tìm số chia nhỏ nhất (Find the Smallest Divisor Given a Threshold)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tìm số chia nhỏ nhất (Find the Smallest Divisor Given a Threshold)
Find the Smallest Divisor Given a Threshold
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integers and a threshold , choose a positive integer to minimize subject to . The ceiling rounds upward to an integer. An answer is guaranteed.
Input
The first line contains . The next line contains values .
Output
Print the smallest divisor.
Subtasks
- Subtask 1 (20 points): ; ; ().
- Subtask 2 (30 points): ; (); .
- Subtask 3 (50 points): ; (); .
Examples
Input 1
4 6
1 2 5 9
Output 1
5
Explanation
At d=4 the sum is 7, at d=5 it is 5. Monotonicity implies 5 is minimal.