PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000188. Tổng kép và phần lẻ (Double Sum 2)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tổng kép và phần lẻ (Double Sum 2)
Double Sum 2
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
For positive integer , let be its odd part, obtained by repeatedly dividing by while it remains even. For instance, , , . Given , compute the exact value
Include diagonal pairs , and count each pair with only once. Do not take a modulus.
Input
The first line contains . The second line contains integers .
Output
Print the exact integer .
Subtasks
-
Subtask 1 (20 points): , .
-
Subtask 2 (30 points): , .
-
Subtask 3 (50 points): , .
Examples
Example 1
Input
2
4 8
Output
5
Explanation
The three pairs have sums , whose odd parts are . Their total is .
Example 2
Input
3
51 44 63
Output
384
Explanation
The six pairs have sums , with odd parts ; their sum is .
Example 3
Input
8
577752 258461 183221 889769 278633 577212 392309 326001
Output
20241214
Explanation
Adding the odd parts of all 36 sums with yields .