All Pairs Similarity
시간 제한2초메모리 제한2048 MB
길이 K인 N개의 비트열 각각에 대해 모든 비트열과의 Jaccard 유사도 합을 구해 1e9+7로 나눈 값을 출력한다.
문제
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 11001 and 11010 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 .
출력
Output the sum modulo for each cow on a separate line.
힌트
The cows are associated with the following bitstrings: 01, 01, 10, 11.
For the first cow, the sum is .
The second cow's bitstring is the same as the first cow's, so her sum is the same as above.
For the third cow, the sum is
.