题目
代码
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+10, M = 110;
int f[N][M];
int main()
{int n, k;cin >> n >> k;for(int i = 1; i <= n; i++){int x;cin >> x;f[i][0] = __gcd(f[i-1][0], x);for(int j = 1; j <= min(i, k); j++){if(i - 1 >= j) f[i][j] = __gcd(f[i-1][j], x);f[i][j] = max(f[i][j], f[i-1][j-1]);}}cout << f[n][k];
}