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 1438. Time Limit Exceeded

Hey! Second test (in sample) is wrong!!!
Posted by AterLux 11 Sep 2010 02:06
Why Value and ValueA is 3 ?
Remainder of -2499999 divided by 6 or -6 is -3 in both cases!
-2499999 / 6 = -416666
-2499999 - (-416666 * 6) = -3
and same for -6.

Please correct tests or describe in task the way to find quotient and remainder of division


Edited by author 11.09.2010 03:13
Re: Hey! Second test (in sample) is wrong!!!
Posted by AterLux 11 Sep 2010 05:49
Got AC using this:

Rem := A mod B;
if Rem < 0 then
  Inc(Rem, Abs(B));

But I still thinking this is not correct, because

A = -123456
B = 321
D = A / B
R = A % B
X = D * B
X = X + R
print A
print X

this both should be the same