#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
using namespace std;
int n;
vector<int> v;
set<int> ans;
map<pair<int, pair<int, int> >, int > memo;
void dp(int N, int i, int summ){
if(N == 1){
ans.insert(summ); return;
}
if(memo[make_pair(N, make_pair(i, summ))] == 1) return;
for(int x = 0; x < (int)v.size(); x++){
if(v[x] >= i && N % v[x] == 0){
dp(N / v[x], v[x], summ + v[x] - 1);
}
}
memo[make_pair(N, make_pair(i, summ))] = 1;
}
signed main(){
cin >> n;
int f = 1;
while(f <= (int)sqrt(n) + 1){
if(n % f == 0){
if(f != 1) v.push_back(f);
if(n/f != f) v.push_back(n/f);
}
f++;
}
dp(n, 0, 0);
cout << (int)ans.size() << "\n";
for(set<int>::iterator it = ans.begin(); it != ans.end(); it++){
cout << (*it) << " ";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
198 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
198 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
198 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
198 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
198 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |