Polish version    English version  
  History of OI -> IX OI 2001/2002


 News
 About Olympic
 History of OI
XVII OI 2009/2010
XVI OI 2008/2009
XV OI 2007/2008
XIV OI 2006/2007
XIII OI 2005/2006
XII OI 2004/2005
XI OI 2003/2004
X OI 2002/2003
IX OI 2001/2002
Schedule
Problems
Stage III - results
Stage II - results
Stage I - results
Stage II
Rules
For contestants
Helpful resources
Stats
VIII OI 2000/2001
VII OI 1999/2000
VI OI 1998/1999
V OI 1997/1998
IV OI 1996/1997
III OI 1995/1996
II OI 1994/1995
I OI 1993/1994
 OI books
 National team
 Olympic camps
 Photo gallery
 Links
 SIO
 MAIN
IX Olimpiada Informatyczna 2001/2002

Task: szy
Author: Szyfr
Cipher

III stage contest  

We are given a sequence of positive integers ai (for i=1,2,...,n). This sequence is used to encrypt n-bit messages. If we have a message consisting of consecutive bits (t1,...,tn) (ti is either 0 or 1), then its encryption it the number:

S=t1a1+t2a2+...+tnan

Task

You are given encrypted messages and sequences of numbers (ai), that have been used to encrypt the messages. Your task is to decrypt the encrypted messages and to save them in particular files. You are not expected to present any program. It is sufficient that you write the decrypted messages.

Input

You are given several sets of data at your disposal. Each set is written in a separate file: szyk.in, where k is the number of the set. In the first line of each file there is one integer n, 5<=n<=40. In the successive n lines there is a sequence of numbers (ai) written: in the line of number i+1 there is one positive integer ai. The sum of the numbers ai does not exceed 2 000 000 000. In the line of number n+2 there is one integer S - the encrypted message, 0<=S<=a1+a2+...+an.

Output

For each set of data szy*.in you should create a file szy*.out containing the decrypted message. In the first line of this file you should write the successive numbers ti, without any spaces between them. The test data were chosen so that the encrypted messages are unambiguously determined.

Example

For the following input file szy.in:
24
19226985
123697
67356296
19721773
1113273
69335448
23680077
9029881
85168664
93676782
5253843
77616588
78572630
13375812
17199980
101508862
59248276
3505733
35790095
62028546
85726819
56462819
103373994
91757169
667509506
the correct answer is in the following output file szy.out:
110001000101101100010101



Print friendly version