|
|
back to boardTest #14 wrong: Any idea why? 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? 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? Andrew, your answer is wrong.. Re: Test #14 wrong: Any idea why? 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? 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 |
|
|