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

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

Please help me, the statement is:

Give N (N <= 10^5) pair (x, y). Count number of triads i, j, k (i != j != k) that (X_i + X_j + X_k) % 3 = 0 and (Y_i +

Y_j + Y_k) % 3 = 0

Example:

Input:

6

1 2

2 5

4 0

8 1

5 3

10 7

Output:

2

Explain: (1,3,6) and (2,4,5)

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

»
18 месяцев назад, # |
Rev. 4   Проголосовать: нравится 0 Проголосовать: не нравится

How many meaningfully different (x, y) pairs can you have?

Spoiler
  • »
    »
    18 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    I thought about this idea, but I don't know how to code :(, please explain more about it

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

      Sorry, I said triads but meant (x, y) pairs.

      Consider them pairs in groups based on their modulus. There's only a few ways to make a valid triad from the different groups and you can figure out how many of each way based on the counts of the groups.