Polish version    English version  
  History of OI -> V OI 1997/1998 -> 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
Stage III - results
Stage II - results
Stage I - results
Problems
Regulations
Schedule
Stats
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
Niebieskie ksi.eczki
V Olimpiada Informatyczna 1997/1998

Task: SUM
Author: Grzegorz Jakacki
Sum of one-sequence

I stage contest  

We say that a sequence of integers is a one-sequence if the difference between any two consecutive numbers in this sequence is 1 or -1 and its first element is 0. More precisely: [a1,a2,...,an] is a one-sequence if

  • for any k, such that 1<=k< n : |ak-ak+1| =1 and
  • a1=0

Task
Write a program that:

  • reads two integers describing the length of the sequence and the sum of its elements, from the text file SUM.IN;
  • finds a one-sequence of the given length whose elements sum up to the given value or states that such a sequence does not exist;
  • writes the result to the text file SUM.OUT.

Input
In the first line of the text file SUM.IN there is a number n, such that 1<=n<=10 000, which is the number of elements in the sequence. In the second line there is a number S, which is the sum of the elements of the sequence, such that |S| <= 50 000 000.

Output
In the first n lines of the text file SUM.OUT there should be written n integers (one in each line) that are the elements of the sequence (k-th element in the k-th line) whose sum is S or the word NIE (which means NO in Polish) if such a sequence does not exist.

Example
For the input file SUM.IN:

8
4
the correct answer is the output file SUM.OUT:
0
1
2
1
0
-1
0
1



Print friendly version