문제
Note: The memory limit for this problem is 512MB, twice the default.
Farmer John's () cows are each assigned a bitstring of length that is not all zero (). Different cows may be assigned the same bitstring.
The Jaccard similarity of two bitstrings is defined as the number of set bits in their bitwise intersection divided by the number of set bits in their bitwise union. For example, the Jaccard similarity of the bitstrings and would be .
For each cow, output the sum of her bitstring's Jaccard similarity with each of the cows' bitstrings including her own, modulo . Specifically, if the sum is equal to a rational number where and are integers sharing no common factors, output the unique integer in the range such that is divisible by .
입력
The first line contains and .
The next lines each contain an integer , representing a cow associated with the length- binary representation of .
예제 입력 1
4 2
1
1
2
3
예제 출력 1
500000006
500000006
500000005
500000006
점수
Inputs 2-15: There will be two test cases for each of .
코드를 제출하려면 로그인이 필요합니다.
로그인