Problem J
Paper Snowflakes
To make a paper snowflake, you fold a sheet of paper in various places and then cut some parts out of the folded sheet. When you unfold the sheet, it can make a very nice pattern. That is, if the folds and cuts are chosen well.
Samantha has recently taken up this hobby but with a “modern
art” twist. To get started, she explores folding a strip of
paper that is
She then performs a series of folds. For the first fold,
Samantha creases the paper
She alternates folding back-and-forth this way. At each
step, she creases the top portion of the paper
She will now cut the paper at
What is the total length of paper in each of the
![\includegraphics[width=0.8\textwidth ]{cut.pdf}](/problems/papersnowflakes/file/statement/en/img-0001.png)
Input
The first line of input consists of three integers
The second line describes the folds. This line contains
The third line describes the cuts. This line contains
Output
Output the total length of paper in each of the
Sample Input 1 | Sample Output 1 |
---|---|
4 2 20 19 17 11 7 1 6 |
5 13 2 |
Sample Input 2 | Sample Output 2 |
---|---|
1 1 10 9 0 |
8 2 |
Sample Input 3 | Sample Output 3 |
---|---|
1 2 1000000000000000000 500000000000000000 0 500000000000000000 |
0 1000000000000000000 0 |