回分類題庫
d304: (1052cp2_ex6) Sum of Hamming Distance
出處:

Difficulity : 3
Accepted : 87 Times | Submit :392 Times | Clicks : 897
Accepted : 52 Users | Submit : 60 Users | Accepted rate : 87%
Time Limit :10000 ms | Memory Limit : 64000 KBytes
題目加入時間 : 2017-03-28 16:17

Content :

The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
Now your job is to find the total Hamming distance between all pairs of the given numbers.
Examples:
Input: 2, 14, 4 Output: 6
Binary representation: 2=“0010”, 14 = “1110”, 4 = “0100”
HamDist( 2, 14 ) + HamDist( 14, 4 ) + HamDist( 4, 2 ) = 2 +2 +2 =6

Input :

Elements of the given array range: 0 <= M <= 10^9
Length of the array: 1 < N <= 10^4
Consider execution time !!!

Output :

Sample Input :

3
2 14 4
4
4 15  9 15

Sample Output :

6
13

Hint :


  

Author :

(管理員:cp2ta)

  Solve it!   Status Forum (0)

C++
C
JAVA
82316. nccucs105703005 (12 ms , 276KB)
82529. nccucs105703009 (8 ms , 382KB)
82702. nccucs103703023 (9 ms , 232KB)
82286. nccucs105703038 (9 ms , 228KB)
82700. nccucs103703023 (10 ms , 226KB)
82359. nccucs105703004 (10 ms , 220KB)
沒有解題記錄

執行時間會受很多因素影響因此僅供參考,主機等級請看這裡