#PS0000304. Tổng trên các mặt nạ con (Subset Zeta Transform)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Tổng trên các mặt nạ con (Subset Zeta Transform)
Subset Zeta Transform
Source: Phước Hưng OJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given a nonnegative integer and a table of integers indexed from through , each index is represented by bits corresponding to a subset of a set of elements. A bit of indicates membership and a bit of indicates nonmembership.
A mask is a submask of , written , if every set bit of is also set in , equivalently . The empty mask and itself are included.
For every mask from through , compute the sum of over all submasks of :
When , only mask exists and .
Input
The first line contains an integer , the number of bits in each mask.
The second line contains integers in increasing mask order.
Output
Print integers on one line in increasing mask order. Do not reduce modulo anything.
Subtasks
- Subtask 1 (20 points): ; (for every ).
- Subtask 2 (30 points): ; (for every ); all values are equal.
- Subtask 3 (50 points): ; (for every ).
Example 1
Input
2
2 -1 3 4
Output
2 1 5 8
Explanation
For , masks have binary representations and .
- .
- .
- .
- .
In increasing mask order the result is 2 1 5 8.
Example 2
Input
0
-7
Output
-7
Explanation
With , . Mask is the only mask and its only submask is itself. Thus ; print -7.