U243978 [COCI2019-2020#4] Spiderman
题目描述
Little Ivan likes to play Yamb and read Marvel superhero comics. His
favorite superhero is spider-man, a friendly neighbourhood teenager named
Peter Parker who got his superpowers via a radioactive spider bite. Ivan
fantasizes that one day he will be able to jump from one skyscraper to
another, just like spider-man does in the comics. During one such fantasy,
he fell asleep.
In his dream he was no longer named Ivan, his name was Peter Parkour and,
you guessed it, he was able to use his parkour1
skills to jump between skyscrapers. He quickly realized that
there are exactly N skyscrapers in his surroundings and he somehow knew that i-th of those skyscrapers
is hi meters tall. He knows that he is able to jump from the i-th skyscraper to the j-th skyscraper if the
remainder when dividing hi with hj is equal to K. Help Ivan determine, for every skyscraper, the number
of other skyscrapers he can jump to.
输入格式
The first line contains two integers N (1 ≤ N ≤ 300 000) and K (0 ≤ K < 1000000
) from the task description.
The next line contains N integers hi (1 ≤ hi ≤ 1000000
) from the task description.
输出格式
In a single line you should output N space-separated integers such that the i-th of those integers represents
the number of different skyscrapers on which Peter Parkour can jump on if he jumps from the i-th
skyscraper.
说明/提示
In test cases worth a total of 14 points, it will hold 1 ≤ N ≤ 2 000
In test cases worth an additional 14 points, there will be at most 2 000 skyscrapers of different heights.
In test cases worth an additional 14 points, it will hold K = 0.