SHARE
TWEET

Untitled

a guest Feb 28th, 2020 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int n,i,st,dr,v[1001],d;
  5.  
  6. int M(int st,int dr)
  7. {
  8.     if(st==dr)
  9. {
  10.                 if(v[st]==1||v[st]==0) return 0;
  11.                 for(d=2;d*d<=v[st];d++)
  12.                     if(v[st]%d==0) return 0;
  13.                 return v[st];
  14.  
  15.         }
  16.      else{
  17.             int mij,max1,max2;
  18.             mij=(st+dr)/2;
  19.             max1=M(st,mij);
  20.             max2=M(mij+1,dr);
  21.               if(max1>max2) return max1;
  22.               else return max2; } }
  23.  
  24. int main()
  25. {
  26.     int n;
  27.     cin >> n;
  28.     for(i=1;i<=n;i++) cin >> v[i];
  29.     cout << M(1,n);
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top