Cod sursa(job #66094)

Utilizator M@2Te4iMatei Misarca M@2Te4i Data 15 iunie 2007 16:10:38
Problema Loto Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.78 kb
#include<stdio.h>

int n;
long a[2],max;
const int w[7]={2, 3, 7, 11, 19, 23, 37};

int euclid()
{
int c=a[0],b=a[1],r;     
while (b)
      {
      r=c%b;
      c=b;
      b=r;
      }
return c;
}     

int numere()
{
long q;
q=euclid();     
for (int i=0; i<=6; i++)
    if (w[i]%q!=0)
       return 1;
return 0;
}     

int main()
{
freopen("poly.in","r",stdin);
scanf("%d",&n); 
scanf("%ld", &a[0]);
long max=0;
int e,q=0;
for (int i=1; i<n; i++)
    {
    scanf("%ld", &a[1]);
    e=numere();
    if (e==0)
       q++;
       else {
            if (q>max)
	       max=q;
	    q=0;
	    }
    a[0]=a[1];
    }
if (q>max)
   max=q;
fclose(stdin);
freopen("poly.out","w",stdout);
printf("%ld",max+1);
fclose(stdout);
return 0;    
}