luogu#P7947. [✗✓OI R1] 铝锤制作

[✗✓OI R1] 铝锤制作

Background

DPair plans to use Midrash to bring smiles to everyone.

Because Lillia does not know what Midrash is, they plan to stop them.

To stop DPair, you need to make a small aluminum hammer.

If you do not know how to make a small aluminum hammer, you can refer to the video provided below the problem.

Or, you can also choose to treat this as the check-in problem for this monthly contest.

Problem Description

Construct a positive integer sequence aa such that the product of all elements in aa is nn, and the sum of all elements is kk. If such a sequence does not exist, output -1.

Input Format

One line contains two positive integers n,kn, k.

Output Format

The first line contains an integer mm, representing the length of the sequence.
The next line contains mm positive integers aia_i, representing the sequence. It is required that 1m10001\leq m \leq 1000 and 1ai10001\leq a_i \leq 1000.
In particular, if there is no sequence that meets the requirements, output -1 directly.

This problem uses a Special Judge. If there are multiple answers, output any one of them.

67 68
2
1 67
100 1
-1
80 16
6
1 1 4 5 1 4

Hint

Sample Explanation

For sample 1, it is clear that 1×67=671\times67=67 and 1+67=681+67=68.
For sample 2, it can be proven that there is no valid solution.

Constraints

For 10%10\% of the testdata, 1n,k31\leq n,k \leq 3.
For 30%30\% of the testdata, 1n,k101\leq n,k \leq 10.
For another 10%10\% of the testdata, n=kn=k.
For 100%100\% of the testdata, 1n,k1001\leq n,k \leq 100.

Translated by ChatGPT 5