1043

JinPeng edited 5 年,1 月前

include

include

int unique[400];
int a[400];

int main() {
int t, n, maxid, flag;
scanf(“%d”, &t);
for(int cas=0;cas<t;cas++) {

    maxid = -1;

    scanf("%d", &n);
    for(int i=0;i<n;i++) {
        scanf("%d", &a[i]);    
        maxid = a[i] > maxid ? a[i] : maxid;
    }
    //printf("maxid: %d\n", maxid);
    int i, j;
    for(i=1;i<=maxid+1;i++) {
        flag = 1;
        j = 0;
        while(j < n) {
            int temp = a[j] % i;
            for(int p=0;p<j;p++) {

                if(temp == unique[p]){flag = 0; break;}

            }
            if(flag == 0)break;
            else{unique[j ++] = temp;}
        }

        if(j == n) {
            printf("%d\n", i);
            break;
        }
    }

}

}

Comments