Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("cmmdcsecv.in");
- ofstream fout("cmmdcsecv.out");
- int a[100003],n;
- int b[1001],prime[1001],k;
- void ciur(int n)
- {
- int i,j;
- for(i=2; i*i<=n; i++)
- if(b[i]==0)
- for (j=i*i; j<=n; j=j+i)
- b[j]=1;
- prime[1]=2;
- k=1;
- for(i=3; i<=n; i+=2)
- if(b[i]==0) prime[++k]=i;
- }
- void citire()
- {
- fin >> n;
- for (int i=1;i<=n;i++)
- fin >> a[i];
- }
- /// ret. lungimea maxima a unei secvente de numere
- /// toate divizibile cu P
- int lungmax(int P)
- {
- int l=0,lgmax=0;
- for (int i=1;i<=n;i++)
- {
- if (a[i]%P==0)l++;
- else l=0;
- lgmax=max(l,lgmax);
- }
- return lgmax;
- }
- void solutie()
- {
- int P,i,l,lmax=0;
- for (i=1;i<=k;i++)
- {
- l=lungmax(prime[i]);
- lmax=max(lmax,l);
- }
- fout << lmax << "\n";
- fout.close();
- }
- int main()
- {
- citire();
- ciur(1000);
- solutie();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement