Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- using namespace std;
- int v[1001];
- int cmmdc (int a , int b)
- {
- while (b!=0)
- {
- int aux = a%b;
- a=b;
- b=aux;
- }
- return a;
- }
- int DivImp (int st , int dr)
- {
- if (st-dr<=1)
- return cmmdc(v[st],v[dr]);
- else
- {
- int mij=(dr+st)/2;
- return cmmdc(DivImp(st,mij),DivImp(mij+1,dr));
- }
- }
- int main()
- {
- // freopen("hanoi.in","r",stdin);
- // freopen("hanoi.out","w",stdout);
- int n;
- cin>>n;
- for (int i=1 ; i<=n ; i++)
- cin>>v[i];
- cout<<DivImp(1,n);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement