ide:-https://ide.geeksforgeeks.org/sIJs9Sbztt
I am not getting any error on gfg please check my code out .As i am getting error in this only .
Getting segmentation fault
Hey @manikjindal49
long long countn(int n){
long long dp[n+1];
Do the above change and it will work fine otherwise overflowing on hackerblocks.
If this resolves your query then please mark it as resolved
Yes when i submit it is shwoing correctbut whenever i tried to compile it is showing same error
Hey @manikjindal49
Its working fine on my side ,please recheck in some time.
I submitted this
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
long long countn(int n){
long long dp[n+1];
int i;
for(i=0;i<=n;i++){
if(i<=2){
dp[i]=i;
}
else{
dp[i]=dp[i-1]+(i-1)*dp[i-2];
}
}
return dp[n];
}
int main() {
int t,n;
cin>>t;
while(t--){
cin>>n;
cout<<countn(n)<<endl;
}
return 0;
}
i AM SAYING IT IS SUBMITTED AND CORRECTED FULLY BUT the thing is whenever iam compiling the code thats showing me error
Can u please share the screenshot
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.