Creating a Sequence

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Kirito is tired of maintaining sequences, so he decides to create them instead!

He thinks of two positive integers, N and K, and then creates a sequence of N non-negative integers that sums to K.

Because he finds this so relaxing, he invites you to join him! However, you find this just a bit boring, so you decide to also minimize the product of your sequence. Can you write a program that creates such a sequence?

Constraints

2 \leq N \leq 100\,000
1 \leq K \leq 1\,000\,000\,000

Scoring

Your program will get 50\% of the points if the N numbers sum to K, and the remaining 50\% if the product is minimized.

Input Specification

The first and only line of input will contain two space separated integers, N and K.

Output Specification

Your program should output a single line: N space-separated non-negative integers that sum to K, such that their product is minimized.

Sample Input

2 926

Sample Output

223 703

Note that the sample output may not be the most optimal solution.


Comments