ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1820. Ural Steaks

Test #14 wrong: Any idea why?
Posted by mashennik 23 May 2012 20:21
Can anybody tell me what is wrong with my code:

var n,k: word;
begin
readln(n,k);
if n > k then
   write( (n mod k) + 2*(n div k) )
else write(2);
end.

I couldn't find any test that my code gives wrong answer.
Re: Test #14 wrong: Any idea why?
Posted by Andrew Sboev 24 May 2012 10:36
Mistake is here.

if n > k then
   write( (n mod k) + 2*n div k )
Multiplication should be before dividing.
Re: Test #14 wrong: Any idea why?
Posted by mashennik 24 May 2012 11:06
Andrew, your answer is wrong..
Re: Test #14 wrong: Any idea why?
Posted by Andrew Sboev 24 May 2012 22:02
Here is my AC solution.

[code deleted]

Edited by author 25.05.2012 11:18
Re: Test #14 wrong: Any idea why?
Posted by Noob 25 May 2012 00:07
Test:
12 10

Edited by author 25.05.2012 00:08
Re: Test #14 wrong: Any idea why?
Posted by Andrew Sboev 25 May 2012 11:18
My solution shows 3. And it is a right answer.

Oh, your code has one more mistake.

if n mod k <> 0 , then you should add 1 to answer, not n mod k.

Edited by author 25.05.2012 11:39