等差数列
#include<iostream> #include<algorithm> using namespace std; const int N = 1e5 + 10; int a[N]; int main() { int n; scanf("%d",&n); for(int i = 0; i < n; i ++) scanf("%d", &a[i]); sort(a, a + n); int d = __gcd(a[1] - a[0], a[2] - a[1]); for(int i = 2; i < n - 1; i ++) { int t = a[i + 1] - a[i]; d = __gcd(d, t); } if(d == 0) { cout << n << endl; return 0; } printf("%d\n", max(n, (a[n - 1] - a[0]) / d + 1)); return 0; }