thanhdat281108
Rating
-
Bài tập
1
Điểm
1149
Rating #
-
Điểm #
29638
Giới thiệu
include <bits/stdc++.h>
define ll long long
define N 100005
using namespace std;
ll a[N];
int n, k;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
freopen("gcd.inp", "r", stdin);
freopen("gcd.out", "w", stdout);
cin >> n >> k;
for (int i = 1; i <= n; ++i) cin >> a[i];
ll res = 0;
for (int i = 1; i <= n - k + 1; ++i)
{
ll g = a[i];
for (int j = 1; j < k; ++j)
{
g = __gcd(g, a[i + j]);
if (g == 1) break;
}
res = max(res, g);
}
cout << res << '\n';
}