From 42d5617483d985101c158beb101f118d47d5ccf5 Mon Sep 17 00:00:00 2001 From: Ren Baoshuo Date: Sat, 13 Nov 2021 15:38:42 +0800 Subject: [PATCH] =?UTF-8?q?T206821=20[=E2=9C=97=E2=9C=93OI=20R1]=20?= =?UTF-8?q?=E9=93=9D=E9=94=A4=E5=88=B6=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit R62441516 --- Luogu/T206821/T206821.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Luogu/T206821/T206821.cpp diff --git a/Luogu/T206821/T206821.cpp b/Luogu/T206821/T206821.cpp new file mode 100644 index 00000000..b85f317b --- /dev/null +++ b/Luogu/T206821/T206821.cpp @@ -0,0 +1,35 @@ +#include + +using namespace std; + +int n, k, s; +vector a, b; + +int main() { + cin >> n >> k; + for (int i = 2; i * i <= n; i++) { + while (n % i == 0) { + a.push_back(i); + n /= i; + } + } + if (n > 1) a.push_back(n); + for (int i : a) { + s += i; + b.push_back(i); + } + if (s > k) { + cout << -1 << endl; + exit(0); + } + while (s < k) { + b.push_back(1); + s++; + } + cout << b.size() << endl; + for (int i : b) { + cout << i << ' '; + } + cout << endl; + return 0; +}