Click here for Problem Statement
SIGSEGV Error is Irritating me a lot . Please help me overcome this problem !
What Should I do to Overcome this SIGSEGV Error. I had allocated memory correctly but still it shows this error
P.S.: My First D.P.
THANKS A LOT IN ADVANCE
#include< iostream >
using namespace std;
long long int mem[1000001],temp;
long long int f(long long int x)
{
if(mem[x])
{
return mem[x];
}
else if(x<6)
{
return x;
}
else
{
temp=f(x/2)+f(x/3)+f(x/4);
}
mem[x]=temp;
return temp;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
long long int n,i;
for ( i = 0 ; i < 1000001 ; i++ )
{
mem [ i ] = 0;
}
while ( cin >> n )
{
cout << max(n,f(n));
cout << endl;
}
return 0;
}