Untitled
raw download clone
TEXT
views 70
,
size 728 b
#include <stdio.h>
#define Max(x, y) ((x>y) ? x:y)
#define min(x, y) ((x>y) ? y:x)
int gcd(int b,int a);
int a[1005],b[10000005];
int gcd(int a,int b)
    {
        if(b==0)
            {
                return a;
            }
        else
            {
                return gcd(b,a%b);
            }
    }
int main() {
    int n,i,j,candy=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if(a[i]!=a[j])
            {
            b[i]=gcd(a[i],a[j]);
            candy=Max(candy,b[i]);
            }
        }
    }// insert code here...
    printf("%d\n",candy);
    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.