Find the Numbers

All submissions for this problem are available.
This is a rather simple problem to describe. You will be given three numbers $S, P$ and $k$. Your task is to find if there are integers $n_1, n_2,...,n_k$ such that $n_1 + n_2 +...+ n_k = S$, $n_1 \cdot n_2 \cdot ... \cdot n_k = P$. If such integers exist, print them out. If no such sequence of integers exist, then print `"NO"`. For example if $S=11, P=48$ and $k=3$ then $3, 4$ and $4$ is a solution. On the other hand, if $S=11, P=100$ and $k=3$, there is no solution and you should print `"NO"`. ###Input: A single line with three integers $S, P$ and $k$. ###Output: A single word `"NO"` or a seqence of $k$ integers $n_1, n_2,..., n_k$ on a single line. (The $n_i$'s must add up to $S$ and their product must be $P$). ###Constraints:  $1 \leq k \leq 4$.  $1 \leq S \leq 1000$.  $1 \leq P \leq 1000$. ###Sample input 1: 11 48 3 ###Sample output 1: 3 4 4 ###Sample input 2: 11 100 3 ###Sample output 2: NOAuthor:  admin2 
Date Added:  17092018 
Time Limit:  2 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions