We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
/* what's wrong with this code tle problem */#include<bits/stdc++.h>usingnamespacestd;longlonggcd(longlonga,longlongb){if(a==0)returnb;returngcd(b%a,a);}longlongfib(longlongc){if(c<=1)returnc;return(fib(c-1)+fib(c-2));}intmain(){longlongintn,ans,p,q;cin>>n;longlonginta[n];for(inti=0;i<n;i++)cin>>a[i];ans=a[0];for(inti=1;i<n;i++)ans=gcd(ans,a[i]);p=fib(ans);cout<<p%1000000007<<endl;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Fibonacci GCD
You are viewing a single comment's thread. Return to all comments →