#include <bits/stdc++.h>
using namespace std;
vector<int> sol;
int n;
void solve(vector<pair<int,int>> v , int cnt , int mult , int pos){
if(pos == v.size()){
int f = 0;
for(auto i : v){
f += i.second;
}
if(mult == 1){
return ;
}
if(f == 0){
sol.push_back(cnt+mult-1);
}
solve(v,cnt+mult-1,1,0);
return ;
}
solve(v,cnt,mult,pos+1);
if(v[pos].second){
vector<pair<int,int>> nv = v;
nv[pos].second -= 1;
solve(nv,cnt,mult*v[pos].first,pos);
}
}
int main(){
cin >> n;
vector<pair<int,int>> v;
for(int i = 2 ; i*i <= n ; i += 1){
if(n%i == 0){
int cnt = 0;
while(n%i == 0){
n /= i;
cnt += 1;
}
v.push_back({i,cnt});
}
}
if(n > 1){
v.push_back({n,1});
}
solve(v,0,1,0);
sort(sol.begin(),sol.end());
sol.erase(unique(sol.begin(),sol.end()),sol.end());
cout << sol.size() << endl;
for(int i : sol){
cout << i << " ";
}cout << endl;
}
Compilation message
toy.cpp: In function 'void solve(std::vector<std::pair<int, int> >, int, int, int)':
toy.cpp:7:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
7 | if(pos == v.size()){
| ~~~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |