File size: 721 Bytes
ff444f7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
#include <iostream>
#include <vector>
using namespace std;
void solve() {
int P;
cin >> P;
int curr_sum = 0;
vector<int> factors;
for (int i = 2; i*i <= P; ) {
if (P % i == 0) {
factors.push_back(i);
curr_sum += i;
P /= i;
} else {
i++;
}
}
if (P > 1) {
curr_sum += P;
factors.push_back(P);
}
if (curr_sum > 41) {
cout << " -1";
return;
}
while (curr_sum < 41) {
factors.push_back(1);
curr_sum++;
}
cout << " " << factors.size();
for (int f : factors) {
cout << " " << f;
}
}
int main() {
int T;
cin >> T;
for (int t = 1; t <= T; t++) {
cout << "Case #" << t << ":";
solve();
cout << endl;
}
return 0;
} |