we have to find the nth term of this series http://oeis.org/A028859
n<=1000000000
answer should be modulo 1000000007
i have written the code but time limit exceeds when n a is huge number.
#include<iostream>
using namespace std
int main()
{
long long int n;
cin>>n;
long long int a,b,c;
a=1;
b=3;
int i;
for(i=3;i<=n;i++)
{
c=(2ll*(a+b))%1000000007;
a=b;
b=c;
}
cout<<c;
}