Pairwise AND sum
All submissions for this problem are available.
You are given a sequence of N integer numbers A. Calculate the sum of Ai AND Aj for all the pairs (i, j) where i < j.
The AND operation is the Bitwise AND operation, defined as in here.
The first line of input consists of the integer N.
The second line contains N integer numbers - the sequence A.
Output the answer to the problem on the first line of the output.
Input: 5 1 2 3 4 5 Output: 9
Subtask 1 (13 points): N <= 1000, Ai <= 1.
Subtask 2 (39 points): N <= 1000, Ai <= 109.
Subtask 3 (21 points): N <= 105, Ai <= 1.
Subtask 4 (27 points): N <= 105, Ai <= 106.
|Tags||ad-hoc, ltime03, xcwgf666|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.5, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.