| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
No_stop#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <cstdlib>
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
const int maxn = 1000005;
const int mask = (1 << 17) - 1;
int a[maxn];
int main() {
ios::sync_with_stdio(false);
int n, i, j, k, t;
cin >> n >> k;
int low = maxn;
for (i = 1; i <= n; ++i) {
cin >> t;
int l = max(0, t - k);
int r = t;
low = min(low, t);
a[l]++, a[r + 1]--;
}
for (i = 1; i < maxn; ++i) {
a[i] += a[i - 1];
}
for (i = low; i >= 1; --i) {
int cnt = 0;
for (j = i; j < maxn; j += i) {
cnt += a[j];
}
if (cnt >= n) {
cout << i << endl;
break;
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator