Data type problem


atcoderdp coin problem
my dp array storing integer by default

@mohitmahi123, you can explicitly typecast it to double
why we need to do that??
eg

int a=3;
int b=2;
double c=a/b ;
cout<<c; // output=1
this is because / operator (which is implemented as a function) sees a and b as int so it will return int as output but if you typecast it as c=(double)©/b;
/ operator sees one of its argument as double so it knows that it had to return double value
cout<<c; // output=1.5000000000 (after overloading)

i have corrected your code: https://ide.codingblocks.com/s/245288 (corrected your memoization as you were not considering nooftails since i and j are always same so don;t store j)

i found my mistake yesterday but in your corrected code u should remove double in line no 15 because it is giving wrong answer.and yes my memoization is wrong. thanks for solving my problem.

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.