• LQDOJ
  • Trang chủ
  • Bài tập
  • Bài nộp
  • Thành viên
  • Kỳ thi
  • Nhóm
  • Giới thiệu
    • Máy chấm
    • Khóa học
    • Đề xuất ý tưởng
    • Đề xuất bài tập
    • Đề xuất kỳ thi
    • Công cụ
    • Báo cáo tiêu cực
    • Báo cáo lỗi

Tiếng Việt

Tiếng Việt
English

Đăng nhập

Đăng ký

thanhdat281108

  • Giới thiệu
  • Bài tập
  • Bài nộp

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';
}


«    »
Thứ 2
Thứ 3
Thứ 4
Thứ 5
Thứ 6
Thứ 7
CN
Ít
Nhiều

proudly powered by DMOJ| developed by LQDJudge team