30 分 k=0暴力枚举 判断
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,k,fl,nw;
int a[1000009];
bool f[1000009];
int main() {
freopen("diff.in","r",stdin);
freopen("diff.out","w",stdout);
int i,j;
cin>>n>>k;
for(i=1;i<=n;i++)
cin>>a[i];
if(k==0) {
for(i=1; ;i++) {
fl=1;
memset(f,0,sizeof(f));
for(j=1;j<=n;j++) {
nw=a[j]%i;
if(f[nw]==0) f[nw]=1;
else {
fl=0;
break;
}
}
if(fl==1) {
cout<<i;
fclose(stdin);
fclose(stdout);
return 0;
}
}
}
}