Блог пользователя divya8080

Автор divya8080, история, 10 месяцев назад, По-английски

I solved this problem(https://www.codechef.com/problems/SORTSUB7EZ) by using the assumption that:- "all the remainders of ai(wrt any integer) belong to set {0, 1, 2, ....,(ai+1)/2-1}" but idk the proof, can anyone help?

PS: i tried a few values of ai and found out that assumption.

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

»
10 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by divya8080 (previous revision, new revision, compare).

»
10 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

to get remainder $$$x \ (2 * x \lt a)$$$ you can do always do $$$a_i mod (a_i - x)$$$ as
$$$y = a_i - x$$$
$$$2y = 2a_i - 2x$$$
$$$a_i + (a_i - 2x) \gt a$$$
$$$2y \gt a$$$

»
10 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hi Divya,

Lets say x is the number and x % d = rem. So this means x = q*d + rem where r < d and hence max value of r can be min(d - 1, x - d).

When will r has it max value? When d - 1 = x - d. So 2d - 1 = x and hence d = (x + 1) / 2. So when we take d - 1 to be r we get r = (x + 1) / 2 - 1. Hope this helps!