Azerbaijan 2022: Qualifying exam in the preparation group for the International Olympiad October 29
Spiderman in Baku
When Spider-Man heard that there are many tall buildings in Baku, he immediately decided to go to Baku. Spider-Man is unable to control himself when he sees the tall buildings here. He began to run from one building to another and jumped without stopping.
There are n buildings in Baku. The height of the i-th building is
After watching Spider-Man for a long time, you saw that he can jump from the i-th building to the j-th building only if the remainder of dividing
hj equals to k.
Your task is to determine, for each building, how many other buildings Spider-Man can jump directly from this building.
The first line contains two integers n (1 ≤ n ≤ 3 *
105) and k (0 ≤ k ≤
106). The next line contains n integers
hn (1 ≤
Print n integers on one line. The i-th of these numbers must be equal to the number of other buildings that Spider-Man can directly jump from the i-th building.
In the third test, you can jump from building 1 to any other building. From building 2 you cannot jump to any other building. From building 3 you can only jump to building 2. From building 4 you can only jump to building 3. You can jump from the building 5 to the buildings 2 and 4.
2 3 9 9
4 3 7 4 17 1
1 0 1 0
5 1 1 2 3 4 5
4 0 1 1 2