0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 13:56:26 +00:00

1991 - 铁憨憨骑士团的课后习题

77473
This commit is contained in:
Baoshuo Ren 2022-09-12 21:35:53 +08:00
parent d69dbf968c
commit f7a8f3f7c5
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

64
bjtu/1991/1991.cpp Normal file
View File

@ -0,0 +1,64 @@
#include <iostream>
#include <numeric>
#include <vector>
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<int> 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<int>(p.size()) + (n - sum) << endl;
for (const int& x : p) {
cout << x << ' ';
}
while (sum < n) {
cout << 1 << ' ';
sum++;
}
cout << endl;
return 0;
}