i am trying to find a fibonnaci number by dp but my code giving runtime error many times.
what may be the problem?
#include <iostream>
#include <cstdio>
using namespace std;
long long int fib(long long int n,long long int *arry){
if (arry[n]!=0)return arry[n];
else if(n==0)return 1;
else
arry[n]=(fib((n-1),arry)+fib((n-2),arry));
return arry[n];
}
int main()
{
long long int *meomarray;
long long int n,t,temp,i;
cin>>t;
while(t--){
cin>>n;
meomarray = new long long int[n+1];
for(i=0;i<=n;i++)meomarray[i]=0;
meomarray[0]=1;
meomarray[1]=1;
temp=fib(n,meomarray);
cout<<temp<<endl;
}
return 0;
}