6960.SOS Bit Problem

Time Limit: 1s Memory Limit: 512MB

Given a list of $n$ integers, your task is to calculate for each element $x$ :

the number of elementsysuch thatx \mid y = xthe number of elementsysuch thatx \mathrel{\&} y = xthe number of elementsysuch thatx \mathrel{\&} y \neq 0

Input Format(From the terminal/stdin)

The first line has an integer $n$ : the size of the list.

The next line has $n$ integers $x_1,x_2,\dots,x_n$ : the elements of the list.

  • $1 \le n \le 2 \cdot 10^5$
  • $1 \le x_i \le 10^6$

Output Format(To the terminal/stdout)

Print $n$ lines: for each element the required values.

Sample Input

Copy
5
3 7 2 9 2
 \n
 · · · · \n

Sample Output

Copy
3 2 5
4 1 5
2 4 4
1 1 3
2 4 4
 · · \n
 · · \n
 · · \n
 · · \n
 · · \n
Source: CSES, Bitwise Operations, 1654

Submit

请先 登录

© 2025 FAQs