PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000161. Singhal và đoạn con GCD lớn nhất (Singhal and GCD)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Singhal và đoạn con GCD lớn nhất (Singhal and GCD)
Singhal and GCD
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Singhal has an array of positive integers . Among all contiguous subarrays of length at least two, choose one with the largest possible GCD. If several subarrays have that GCD, choose the longest among them. Output both the maximum GCD and the selected length.
Input
The first line contains . The second line contains the integers .
Output
Print two space-separated integers: the maximum GCD and the greatest length of a subarray achieving it.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
3
3 6 9
Output
3 3
Explanation
The GCD of each of , and is . The third subarray is the longest among those achieving the maximum GCD, so print 3 3.