|
|
back to boardShow all messages Hide all messagesCan 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. Mistake is here. if n > k then write( (n mod k) + 2*n div k ) Multiplication should be before dividing. Andrew, your answer is wrong.. Here is my AC solution. [code deleted] Edited by author 25.05.2012 11:18 Test: 12 10 Edited by author 25.05.2012 00:08 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 |
|
|