Polish version    English version  
  History of OI -> II OI 1994/1995 -> Problems


 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
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
Stage III - results
Stage I - results
Problems
I OI 1993/1994
 OI books
 National team
 Olympic camps
 Photo gallery
 Links
 SIO
 MAIN
Niebieskie ksi.eczki
II Olympiad in Informatics 1994/1995

Task: JED
Author: Andrzej Walat*
Ones And Zeros

I stage contest  

Certain positive integers have their decimal representation consisting only of ones and zeros, and having at least one digit one, e.g. 101. If a positive integer has not such a property, one can try to multiply it by some positive integer to find out whether the product has this property.

Task

Write a program that:

  • reads from the text file JED.IN positive integers n not greater than 20000,
  • for each integer read computes a correct answer,
  • writes the answer to the text file JED.OUT.
The answer is either a positive multiple of n whose decimal representation consists of at most 100 (a hundred) digits, only zeros or ones, or the word BRAK ("absence"), if there is no such multiple.

Input

The file JED.IN contains in the first line a positive integer K<1000. In consecutive lines there is a sequence of K numbers in the range of [1..20000], one number per line. The numbers in the file JED.IN are written correctly, and your program need not verify that.

Output

Each line of the file JED.OUT, starting with the first, should contain:

  • either only one word BRAK,
  • or exactly one positive integer being a multiple of a successive number given in the input; each multiple must be a number composed only of digits 0 and 1, and has to be written with no spaces between the digits.
The answers are to be written in JED.OUT in the same order as the corresponding numbers in JED.IN.

Example

For the file JED.IN:
6
17
11011
17
999
125
173
the file JED.OUT may have the following form:
11101
11011
11101
111111111111111111111111111
1000
1011001101

Your program should look for the file JED.IN in the current directory and create the file JED.OUT also in the current directory. The source file containing the program written by you should be named JED.???, where ??? are substituted by at most three-letter abbreviation of the programming language used. The same program in an executable form should be written in a file JED.EXE.


* The task comes from a collection of Romanian problems. Dr. Andrzej Walat has compiled the contents and he is the author of the solutions.




Print friendly version