#1343
Unrated
Knapsack Cryptosystem
시간 제한
3s
메모리 제한
512MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

The Merkle–Hellman Knapsack Cryptosystem was one of the earliest public key cryptosystems invented by Ralph Merkle and Martin Hellman in 1978. Here is its description.

Alice chooses nn positive integers {a1,,an}\{a_1, \ldots, a_n\} such that each ai>j=1i1aja_i > \sum_{j=1}^{i-1} a_j, a positive integer qq which is greater than the sum of all aia_i, and a positive integer rr which is coprime with qq. These n+2n+2 integers are Alice's private key.

Then Alice calculates bi=(air)modqb_i = (a_i \cdot r) \bmod q. These nn integers are Alice's public key.

Knowing her public key, Bob can transmit a message of nn bits to Alice. To do that he calculates ss, the sum of bib_i with indices ii such that his message has bit 11 in ii-th position. This value ss is the encrypted message.

Note that an eavesdropper Eve, who knows the encrypted message and the public key, has to solve a (presumably hard) instance of the knapsack problem to find the original message. Meanwhile, after receiving ss, Alice can calculate the original message in linear time; we leave it to you as an exercise.

In this problem you deal with the implementation of the Merkle–Hellman Knapsack Cryptosystem in which Alice chose q=264q=2^{64}, for obvious performance reasons, and published this information. Since everyone knows her qq, she asks Bob to send her the calculated value ss taken modulo 2642^{64} for simplicity of communication.

You are to break this implementation. Given the public key and an encrypted message, restore the original message.

입력

The first line contains one integer nn (1n641 \le n \le 64).

Each of the next nn lines contains one integer bib_i (1bi<2641 \le b_i < 2^{64}).

The last line contains one integer smodqs \bmod q — the encrypted message ss taken modulo qq (0smodq<2640 \le s \bmod q < 2^{64}).

The given sequence bib_i is a valid public key in the described implementation, and the given value smodqs \bmod q is a valid encrypted message.

출력

Output exactly nn bits (0 or 1 digits) — the original message.

예제 입력 1

5
10
20
50
140
420
440

예제 출력 1

01001
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.