Hi, I’m getting the exact output as shown for the test case(0th test case) but it shows that I have failed the test case. I have been facing this exact problem for a lot of questions now (expecially the ones involving many input test cases). Also I’m not getting a shareable link for the code I had written in the coding blocks IDE. So I have pasted my code below.
#include
using namespace std;
#define int long long int
int Binary(int n, int dp[])
{
if(n<0)
return 1;
if(n==0)
return dp[n]=1;
else
{
if(dp[n]!=0)
return dp[n];
return dp[n]= Binary(n-1, dp)+ Binary(n-2, dp);
}
}
int32_t main() {
int T;
cin>>T;
for(int i=0;i<T;i++)
{
int n;
cin>>n;
int dp[n+1]={0};
int result= Binary(n, dp);
cout<<result<<endl;
}
}