rt,只会暴力.
For(m, 2, max){ memset(cnt, 0, sizeof cnt); int tot = 0; For(i, 1, n){ if(cnt[a[i] % m] == 0) tot ++; cnt[a[i] % m] ++; } if(tot < ans){ ans = tot; w = m; } if(ans == 1) break; }