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

Автор TuHoangAnh, история, 4 года назад, По-английски

given an array consists of $$$n$$$ integers and an integer $$$p$$$, find number of pair($$$i,j$$$):

so that $$$i \lt j$$$ and $$$(a[i]*a[j])$$$ $$$mod$$$ $$$p$$$ $$$=$$$ $$$(a[i]+a[j])$$$ $$$mod$$$ $$$p$$$

$$$n \lt =10^5$$$

$$$1 \lt p \lt =10^9$$$

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

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

Im not sure if this really works, but this is what I thought: rearranging the expression, we have $$$a_i \cdot a_j - (a_i+a_j) \equiv 0 \mod{p}$$$, which is equivalent to $$$(a_i-1)(a_j-1) \equiv 1 \mod{p}.$$$ This implies that $$$a_i \equiv a_j \equiv 0$$$ or $$$2 \mod{p}$$$. Then, let $$$x$$$ be the number of $$$a_k$$$ such that $$$a_k \equiv 0 \mod{p}$$$ and $$$y$$$ the number of $$$a_l$$$ such that $$$a_l \equiv 2 \mod{p}$$$. Answer is $$${x \choose 2} + {y \choose 2}$$$.

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

please give the problem link