/*input
36
*/
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define MNTO(x,y) x=min(x,y)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define ll long long
#define ld long double
#define sz(x) (int)x.size()
#define pb push_back
#define unq(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const int maxn=2e4+5;
map<int,vector<int>> dp;
vector<int> rec(int n){
if(n==1){
vector<int> vv;
return vv;
}
if(dp.count(n)) return dp[n];
vector<int> vv={n-1};
for(int i=2;i<=sqrt(n);i++){
if(n%i==0){
auto z=rec(n/i);
for(int a:z) vv.pb(a+(i-1));
}
}
unq(vv);
return dp[n]=vv;
}
int main(){
ios::sync_with_stdio(false),cin.tie(0);
int n;
cin>>n;
auto z=rec(n);
unq(z);
cout<<sz(z)<<'\n';
for(int x:z) cout<<x<<' ';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |