From 7142277b40dd380cbf82f962d8bdd8612e5d4d41 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Tue, 13 Sep 2022 09:01:51 +0800 Subject: [PATCH] =?UTF-8?q?1996=20-=20=E9=93=81=E6=86=A8=E6=86=A8=E9=AA=91?= =?UTF-8?q?=E5=A3=AB=E5=9B=A2=E7=9A=84=E8=AF=BE=E5=90=8E=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 77493 --- bjtu/1996/1996.cpp | 64 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 bjtu/1996/1996.cpp diff --git a/bjtu/1996/1996.cpp b/bjtu/1996/1996.cpp new file mode 100644 index 00000000..fcefbae2 --- /dev/null +++ b/bjtu/1996/1996.cpp @@ -0,0 +1,64 @@ +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +bool is_prime(int x) { + if (x <= 1) return false; + + for (int i = 2; i * i <= x; i++) { + if (x % i == 0) { + return false; + } + } + + return true; +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + int n, t; + std::vector p; + + cin >> n; + + if (is_prime(n)) { + cout << "NO" << endl; + + exit(0); + } + + t = n; + + for (int i = 2; i * i <= t; i++) { + while (t % i == 0) { + p.emplace_back(i); + t /= i; + } + } + + if (t > 1) p.emplace_back(t); + + int sum = std::accumulate(p.begin(), p.end(), 0); + + cout << "YES" << endl + << static_cast(p.size()) + (n - sum) << endl; + + for (const int& x : p) { + cout << x << ' '; + } + + while (sum < n) { + cout << 1 << ' '; + sum++; + } + + cout << endl; + + return 0; +}