#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n;
set<ll> res;
vector<ll> divv;
void gen(ll mult, ll sum, ll last){
//cout<<k<<" "<<sum<<" "<<mult<<endl;
if(mult==1){
res.insert(sum);
return;
}
for(auto i : divv){
//cout<<i<<" "<<mult*i<<" "<<n%(mult*i)<<endl;
if(i<last)continue;
if(mult%i==0){
gen(mult/i, sum+i-1, i);
}
}
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(nullptr);
cin>>n;
for(int i = 1; i*i <= n; i++){
if(n%i==0){
divv.push_back(i);
if(n/i!=i)divv.push_back(n/i);
}
}
gen(n, 0, 0);
cout<<res.size()<<"\n";
for(auto i : res){
cout<<i<<" ";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
126 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 |
126 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 |
126 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 |
126 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 |
126 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |