You are not logged in. Please login at www.codechef.com to post your questions!

×

[closed] simple problem still getting wrong answer please help

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.

asked 08 Jun '14, 12:53

aniket20's gravatar image

6★aniket20
2962712
accept rate: 0%

closed 22 Jul '14, 22:44

The question has been closed for the following reason "The question is answered, right answer was accepted" by aniket20 22 Jul '14, 22:44


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")

}

link

answered 22 Jul '14, 22:38

prem_93's gravatar image

3★prem_93
6233816
accept rate: 19%

edited 22 Jul '14, 22:44

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×978
×322
×249
×3

question asked: 08 Jun '14, 12:53

question was seen: 956 times

last updated: 22 Jul '14, 22:44