#include <bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define disc(x) sort(all(x));x.resize(unique(all(x))-x.begin());
int n,m,cur=1,vis[1025];
vector<int> p,f,nums[1025];
unordered_map<int,int> idx;
void gen_fac(int i){
if(i==sz(p)){
if(cur!=1)f.pb(cur);
return;
}
gen_fac(i+1);
cur*=p[i];
gen_fac(i+1);
cur/=p[i];
}
void dp(int x){
if(x==1)return;
int y=idx[x];
if(vis[y])return;
vis[y]=true;
for(int i=0;i<m;++i){
//pf("i: %d %d\n",i,f[i]);
if(x%f[i]==0){
dp(x/f[i]);
int t;
if(x/f[i]==1)t=m;
else t=idx[x/f[i]];
for(int j:nums[t]){
nums[y].pb(j+f[i]-1);
}
disc(nums[y]);
}
}
}
int main(){
sf("%d",&n);
if(n==1)pf("0\n"),exit(0);
int _n=n;
for(int i=2;i*i<=n;++i){
while(n%i==0)p.pb(i),n/=i;
}
if(n!=1)p.pb(n);
n=_n;
gen_fac(0);
disc(f);
m=sz(f);
for(int i=0;i<m;++i){
idx[f[i]]=i;
}
nums[m].pb(0);
dp(n);
pf("%d\n",sz(nums[m-1]));
for(int i:nums[m-1])pf("%d ",i);
pf("\n");
}
Compilation message
toy.cpp: In function 'int main()':
toy.cpp:47:4: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
47 | sf("%d",&n);
| ^
# |
결과 |
실행 시간 |
메모리 |
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 |
- |