package 刷题;import java.util.Scanner;import java.util.Arrays;publicclass 初赛2019等差数列2{publicstaticvoidmain(String[] args){
Scanner sc =newScanner(System.in);
int n = sc.nextInt();
int [] a =newint[n+1];for(int i =1;i<=n;i++){
a[i]= sc.nextInt();}
Arrays.sort(a);
int cz = a[n]-a[1];//求最大值与最小值的差
int c = a[2]-a[1];for(int i=2;i<=n;i++){
a[i]= a[i]-a[1];
c =gcd(a[i],c);//求最小公倍数}// System.out.println("min"+min);if(c ==0){
System.out.println(n);// }else System.out.println(cz/c+1);}static int gcd(int a,int b){//求最大公因子 不用考虑a,b 的大小if(b==0)return a;elsereturngcd(b,a%b);}}
初赛2019等差数列 javapackage 刷题;import java.util.Scanner;import java.util.Arrays;public class 初赛2019等差数列2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int [] a = new int [n+1]; for(int i =1;