simple problem still getting wrong answer please help

beginner
doubt
plzlykme
simple

#1

http://www.codechef.com/viewsolution/3958031
this is my code and i think my logic is correct but still its showing wrong answer can somebody tell me the fault. thanks in advance.


#2

i went through your code.your logic is right but implentation is wrong.
the condition is:s*((1+c)^d-1)>=l;
this is the same condition you have used but to check this condition ,there is no need to find value of
s*((1+c)^d-1),which is the wrong you have commited.long long int can store up to 10^18 only but the left hand side value will be much more than that resulting in overflow which is the reason for your wrong answer. A simple implementation like this would suffice:

Psuedo Code:

{

c++;

long long int count=1;

while(s<l)

{

s=s*c;

count++;

}

if(d>=count)

print(“ALIVE AND KICKING”)

else

print(“DEAD AND ROTTING”)

}