Spiderman

 2 Sec 512 MB |  Markdown 获取标签
121558
通过人数尝试人数总提交数

 

题目描述

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 parkour skills to jump between skyscrapers. He quickly realized that there are exactly NN skyscrapers in his surroundings and he somehow knew that ii-th of those skyscrapers is hih_i meters tall. He knows that he is able to jump from the ii-th skyscraper to the jj-th skyscraper if the remainder when dividing hih_i with hjh_j is equal to KK. Help Ivan determine, for every skyscraper, the number of other skyscrapers he can jump to.

输入格式

The first line contains two integers NN (1N300000)(1 \le N \le 300,000) and KK (0K<106)(0 \le K \lt 10^6) from the task description.

The next line contains NN integers hih_i (1hi106)(1 \le h_i \le 10^6) from the task description.

输出格式

In a single line you should output NN space-separated integers such that the ii-th of those integers represents the number of different skyscrapers on which Peter Parkour can jump on if he jumps from the ii-th skyscraper.

样例输入 #1

2 1
5 5

样例输出 #1

0 0

样例输入 #2

6 3
4 3 12 6 8 2

样例输出 #2

0 4 0 0 0 0

样例输入 #3

5 1
1 3 5 7 2

样例输出 #3

4 1 1 2 0

提示

Clarification of the third example:

From the first skyscraper of height 11 Peter can jump on any other skyscraper.

From the second skyscraper of height 33 Peter can jump only on a skyscraper of height 22.

From the third skyscraper of height 55 Peter can jump only on a skyscraper of height 22.

From the fourth skyscraper of height 77 Peter can jump on skyscrapers of heights 22 and 33.

From the fifth skyscraper of height 22 Peter cannot jump on any other skyscraper.

来源

COCI 2019/2020 CONTEST #4

 

 您尚未登录,无法进行代码提交

2023 春季 组队排位赛(三)

2023-03-19 12:30
2023-03-19 17:30
Ended