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

Give me answer for my question. Please!
Posted by {AESC USU} Evgeny Kurpilyanskij 13 Feb 2007 08:00
if (a == b*q+p) and (0 <= p < |b|) then
{
  q == a / b
  p == a % b
}

is it TRUE?

Edited by author 13.02.2007 14:34
Re: Give me answer for my question. Please!
Posted by [SPbSU ITMO] WiNGeR 13 Feb 2007 17:46
a % b == p - correct
a / b is standard (just a / b in your programming language)
Re: Give me answer for my question. Please!
Posted by {AESC USU} Evgeny Kurpilyanskij 13 Feb 2007 18:57
To WiNGeR:
I should use SIGHNED INT32 or UNSIGHNED INT32

P.S. Sorry for bad English.

Edited by author 13.02.2007 18:57
Re: Give me answer for my question. Please!
Posted by [SPbSU ITMO] WiNGeR 13 Feb 2007 23:39
SIGNED INT32
Re: Give me answer for my question. Please!
Posted by AterLux 11 Sep 2010 02:30
0 <= |p| < |b| correct
because if p = a - b * q, and q = a / b, you can see, p should be negative for negative a.
But sample test provides positive remainder. I think this is mistake in tests.
Use this
p = a % b;
if (p < 0) p += abs(b);

Edited by author 11.09.2010 05:45