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

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

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
  • Проголосовать: не нравится

»
16 месяцев назад, скрыть # |
 
Проголосовать: нравится +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$$$