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:-----
NO

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
def findCombo(s, p, k):
	if k == 1:
		if s == p:
			return [s]
		else:
			return []
	else:
		for i in range(1, s):
			if p % i == 0 and i < s:
				ans = findCombo(s - i, p // i, k - 1)
				if len(ans) != 0:
					ans.append(i)
					return ans
		return []
try:
	(s, p, k) = map(int, input().split())
	ans = findCombo(s, p, k)
	if len(ans) == 0:
		print('NO')
	else:
		print(*ans)
except:
	pass


import sys

def IOE():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	(s, p, k) = map(int, sys.stdin.readline().split())
	if k == 1:
		if s == p:
			print(s)
		else:
			print('NO')
	if k == 2:
		for i in range(s // 2 + 1):
			if i * (s - i) == p:
				print(i, s - i)
				break
		else:
			print('NO')
	if k == 3:
		ans = []
		for i in range(s // 3 + 1):
			for j in range(s // 3 + 2):
				if i * j * (s - i - j) == p:
					ans.append([i, j, s - i - j])
		if len(ans):
			print(*ans[0])
		else:
			print('NO')
	if k == 4:
		ans = []
		for i in range(s // 4 + 1):
			for j in range(s // 4 + 2):
				for k in range(s // 4 + 3):
					if i * j * k * (s - i - j - k) == p:
						ans.append([i, j, k, s - i - j - k])
		if len(ans):
			print(*ans[0])
		else:
			print('NO')

def __starting_point():
	main()
__starting_point()


from itertools import permutations as pp
from functools import reduce
try:
	(s, p, k) = map(int, input().split())
	x = []
	n = int(p ** 0.5) + 1
	for i in range(1, n):
		if p % i == 0:
			if i < s:
				x.append(i)
			if p // i < s:
				x.append(p // i)
	x = x * k
	x = list(set(pp(x, k)))
	n = len(x)
	flag = 1
	for i in x:
		if s == sum(i) and p == reduce(lambda a, b: a * b, i):
			print(*i)
			flag = 0
			break
	if flag:
		print('NO')
except:
	pass


import math

def part(n, k):

	def _part(n, k, pre):
		if n <= 0:
			return []
		if k == 1:
			if n <= pre:
				return [[n]]
			return []
		ret = []
		for i in range(min(pre, n), 0, -1):
			ret += [[i] + sub for sub in _part(n - i, k - 1, i)]
		return ret
	return _part(n, k, n)
(S, P, k) = map(int, input().split())
factors = []
for i in range(1, int(math.sqrt(P)) + 1):
	if P % i == 0 and P // i != i:
		factors.append(i)
		factors.append(P // i)
	elif P % i == 0 and P // i == i:
		factors.append(i)
arr = part(S, k)
flag = -1
for i in arr:
	temp = i
	cnt = 0
	prod = 1
	for j in temp:
		if j in factors:
			cnt += 1
		prod *= j
	if cnt == k and prod == P:
		print(*temp)
		flag = 0
		break
	else:
		flag = 1
if flag != 0:
	print('NO')