#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define pi pair<ll,ll>
using namespace std;
vector<pair<ll,ll> > pf;
ll n;
vector<ll> power[109];
set<ll> ans;
void bt(vector<int> last,vector<int> cur,int SumBefore,int curnum,bool larger){
bool IsEnd = cur.empty();
for(auto o:pf)
if(o.second)
IsEnd = 0;
if(IsEnd){
ans.insert(SumBefore);
return ;
}
int Divisor = cur.size();
for(int i=(larger?0:last[Divisor]);i<=pf[Divisor].second;i++){
cur.pb(i);
curnum*= power[Divisor][i];
pf[Divisor].second -= i;
if(cur.size() == pf.size() && curnum>1)
bt(cur,{},SumBefore+curnum-1,1,larger |(i>last[Divisor] ) );
else if(cur.size() < pf.size())
bt(last,cur,SumBefore,curnum,larger |(i>last[Divisor] ) );
curnum /= power[Divisor][i];
cur.pop_back();
pf[Divisor].second += i;
}
}
signed main(){
cin>>n;
for(ll i=2;i*i<=n;i++){
ll cnt = 0;
while( (n%i) == 0)
cnt++,n/=i;
if(cnt > 0){
pf.pb(pi(i,cnt));
power[ pf.size()-1 ].pb(1);
for(ll j=1;j<=cnt;j++)
power[ pf.size()-1 ].pb( power[ pf.size()-1 ].back()*i );
}
}
if(n != 1){
pf.pb(pi(n,1));
power[ pf.size()-1 ].pb(1);
for(ll j=1;j<=1;j++)
power[ pf.size()-1 ].pb( power[ pf.size()-1 ].back()*n );
}
// for(auto o:pf)
// cout<<o.first<<" "<<o.second<<endl;
vector<int> ls(pf.size(),0);
bt(ls,{},0,1,0);
cout<<ans.size()<<endl;
for(auto o:ans)
cout<<o<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
300 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
296 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
0 ms |
204 KB |
Output is correct |
23 |
Correct |
0 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
300 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
296 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
0 ms |
204 KB |
Output is correct |
23 |
Correct |
0 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
35 ms |
288 KB |
Output is correct |
27 |
Correct |
20 ms |
312 KB |
Output is correct |
28 |
Correct |
9 ms |
204 KB |
Output is correct |
29 |
Correct |
4 ms |
204 KB |
Output is correct |
30 |
Correct |
2 ms |
204 KB |
Output is correct |
31 |
Correct |
59 ms |
296 KB |
Output is correct |
32 |
Correct |
25 ms |
204 KB |
Output is correct |
33 |
Correct |
29 ms |
204 KB |
Output is correct |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
1 ms |
204 KB |
Output is correct |
37 |
Correct |
12 ms |
292 KB |
Output is correct |
38 |
Correct |
2 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
300 KB |
Output is correct |
40 |
Correct |
10 ms |
204 KB |
Output is correct |
41 |
Correct |
1 ms |
204 KB |
Output is correct |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
43 |
Correct |
1 ms |
204 KB |
Output is correct |
44 |
Correct |
1 ms |
204 KB |
Output is correct |
45 |
Correct |
2 ms |
204 KB |
Output is correct |
46 |
Correct |
0 ms |
204 KB |
Output is correct |
47 |
Correct |
12 ms |
204 KB |
Output is correct |
48 |
Correct |
0 ms |
204 KB |
Output is correct |
49 |
Correct |
2 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
300 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
296 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
0 ms |
204 KB |
Output is correct |
23 |
Correct |
0 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
35 ms |
288 KB |
Output is correct |
27 |
Correct |
20 ms |
312 KB |
Output is correct |
28 |
Correct |
9 ms |
204 KB |
Output is correct |
29 |
Correct |
4 ms |
204 KB |
Output is correct |
30 |
Correct |
2 ms |
204 KB |
Output is correct |
31 |
Correct |
59 ms |
296 KB |
Output is correct |
32 |
Correct |
25 ms |
204 KB |
Output is correct |
33 |
Correct |
29 ms |
204 KB |
Output is correct |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
1 ms |
204 KB |
Output is correct |
37 |
Correct |
12 ms |
292 KB |
Output is correct |
38 |
Correct |
2 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
300 KB |
Output is correct |
40 |
Correct |
10 ms |
204 KB |
Output is correct |
41 |
Correct |
1 ms |
204 KB |
Output is correct |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
43 |
Correct |
1 ms |
204 KB |
Output is correct |
44 |
Correct |
1 ms |
204 KB |
Output is correct |
45 |
Correct |
2 ms |
204 KB |
Output is correct |
46 |
Correct |
0 ms |
204 KB |
Output is correct |
47 |
Correct |
12 ms |
204 KB |
Output is correct |
48 |
Correct |
0 ms |
204 KB |
Output is correct |
49 |
Correct |
2 ms |
204 KB |
Output is correct |
50 |
Correct |
402 ms |
324 KB |
Output is correct |
51 |
Correct |
335 ms |
304 KB |
Output is correct |
52 |
Correct |
483 ms |
304 KB |
Output is correct |
53 |
Correct |
407 ms |
304 KB |
Output is correct |
54 |
Correct |
93 ms |
308 KB |
Output is correct |
55 |
Correct |
1518 ms |
316 KB |
Output is correct |
56 |
Correct |
1755 ms |
300 KB |
Output is correct |
57 |
Correct |
665 ms |
552 KB |
Output is correct |
58 |
Correct |
1 ms |
204 KB |
Output is correct |
59 |
Correct |
1 ms |
204 KB |
Output is correct |
60 |
Correct |
7 ms |
204 KB |
Output is correct |
61 |
Correct |
374 ms |
300 KB |
Output is correct |
62 |
Correct |
41 ms |
304 KB |
Output is correct |
63 |
Correct |
12 ms |
204 KB |
Output is correct |
64 |
Correct |
1 ms |
204 KB |
Output is correct |
65 |
Correct |
131 ms |
204 KB |
Output is correct |
66 |
Correct |
0 ms |
204 KB |
Output is correct |
67 |
Correct |
1 ms |
204 KB |
Output is correct |
68 |
Correct |
1 ms |
204 KB |
Output is correct |
69 |
Correct |
4 ms |
296 KB |
Output is correct |
70 |
Correct |
37 ms |
296 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
300 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
296 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
0 ms |
204 KB |
Output is correct |
23 |
Correct |
0 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
35 ms |
288 KB |
Output is correct |
27 |
Correct |
20 ms |
312 KB |
Output is correct |
28 |
Correct |
9 ms |
204 KB |
Output is correct |
29 |
Correct |
4 ms |
204 KB |
Output is correct |
30 |
Correct |
2 ms |
204 KB |
Output is correct |
31 |
Correct |
59 ms |
296 KB |
Output is correct |
32 |
Correct |
25 ms |
204 KB |
Output is correct |
33 |
Correct |
29 ms |
204 KB |
Output is correct |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
1 ms |
204 KB |
Output is correct |
37 |
Correct |
12 ms |
292 KB |
Output is correct |
38 |
Correct |
2 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
300 KB |
Output is correct |
40 |
Correct |
10 ms |
204 KB |
Output is correct |
41 |
Correct |
1 ms |
204 KB |
Output is correct |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
43 |
Correct |
1 ms |
204 KB |
Output is correct |
44 |
Correct |
1 ms |
204 KB |
Output is correct |
45 |
Correct |
2 ms |
204 KB |
Output is correct |
46 |
Correct |
0 ms |
204 KB |
Output is correct |
47 |
Correct |
12 ms |
204 KB |
Output is correct |
48 |
Correct |
0 ms |
204 KB |
Output is correct |
49 |
Correct |
2 ms |
204 KB |
Output is correct |
50 |
Correct |
402 ms |
324 KB |
Output is correct |
51 |
Correct |
335 ms |
304 KB |
Output is correct |
52 |
Correct |
483 ms |
304 KB |
Output is correct |
53 |
Correct |
407 ms |
304 KB |
Output is correct |
54 |
Correct |
93 ms |
308 KB |
Output is correct |
55 |
Correct |
1518 ms |
316 KB |
Output is correct |
56 |
Correct |
1755 ms |
300 KB |
Output is correct |
57 |
Correct |
665 ms |
552 KB |
Output is correct |
58 |
Correct |
1 ms |
204 KB |
Output is correct |
59 |
Correct |
1 ms |
204 KB |
Output is correct |
60 |
Correct |
7 ms |
204 KB |
Output is correct |
61 |
Correct |
374 ms |
300 KB |
Output is correct |
62 |
Correct |
41 ms |
304 KB |
Output is correct |
63 |
Correct |
12 ms |
204 KB |
Output is correct |
64 |
Correct |
1 ms |
204 KB |
Output is correct |
65 |
Correct |
131 ms |
204 KB |
Output is correct |
66 |
Correct |
0 ms |
204 KB |
Output is correct |
67 |
Correct |
1 ms |
204 KB |
Output is correct |
68 |
Correct |
1 ms |
204 KB |
Output is correct |
69 |
Correct |
4 ms |
296 KB |
Output is correct |
70 |
Correct |
37 ms |
296 KB |
Output is correct |
71 |
Execution timed out |
5037 ms |
720 KB |
Time limit exceeded |
72 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
300 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
296 KB |
Output is correct |
11 |
Correct |
0 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
204 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
1 ms |
204 KB |
Output is correct |
22 |
Correct |
0 ms |
204 KB |
Output is correct |
23 |
Correct |
0 ms |
204 KB |
Output is correct |
24 |
Correct |
1 ms |
204 KB |
Output is correct |
25 |
Correct |
1 ms |
204 KB |
Output is correct |
26 |
Correct |
35 ms |
288 KB |
Output is correct |
27 |
Correct |
20 ms |
312 KB |
Output is correct |
28 |
Correct |
9 ms |
204 KB |
Output is correct |
29 |
Correct |
4 ms |
204 KB |
Output is correct |
30 |
Correct |
2 ms |
204 KB |
Output is correct |
31 |
Correct |
59 ms |
296 KB |
Output is correct |
32 |
Correct |
25 ms |
204 KB |
Output is correct |
33 |
Correct |
29 ms |
204 KB |
Output is correct |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
1 ms |
204 KB |
Output is correct |
37 |
Correct |
12 ms |
292 KB |
Output is correct |
38 |
Correct |
2 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
300 KB |
Output is correct |
40 |
Correct |
10 ms |
204 KB |
Output is correct |
41 |
Correct |
1 ms |
204 KB |
Output is correct |
42 |
Correct |
1 ms |
204 KB |
Output is correct |
43 |
Correct |
1 ms |
204 KB |
Output is correct |
44 |
Correct |
1 ms |
204 KB |
Output is correct |
45 |
Correct |
2 ms |
204 KB |
Output is correct |
46 |
Correct |
0 ms |
204 KB |
Output is correct |
47 |
Correct |
12 ms |
204 KB |
Output is correct |
48 |
Correct |
0 ms |
204 KB |
Output is correct |
49 |
Correct |
2 ms |
204 KB |
Output is correct |
50 |
Correct |
402 ms |
324 KB |
Output is correct |
51 |
Correct |
335 ms |
304 KB |
Output is correct |
52 |
Correct |
483 ms |
304 KB |
Output is correct |
53 |
Correct |
407 ms |
304 KB |
Output is correct |
54 |
Correct |
93 ms |
308 KB |
Output is correct |
55 |
Correct |
1518 ms |
316 KB |
Output is correct |
56 |
Correct |
1755 ms |
300 KB |
Output is correct |
57 |
Correct |
665 ms |
552 KB |
Output is correct |
58 |
Correct |
1 ms |
204 KB |
Output is correct |
59 |
Correct |
1 ms |
204 KB |
Output is correct |
60 |
Correct |
7 ms |
204 KB |
Output is correct |
61 |
Correct |
374 ms |
300 KB |
Output is correct |
62 |
Correct |
41 ms |
304 KB |
Output is correct |
63 |
Correct |
12 ms |
204 KB |
Output is correct |
64 |
Correct |
1 ms |
204 KB |
Output is correct |
65 |
Correct |
131 ms |
204 KB |
Output is correct |
66 |
Correct |
0 ms |
204 KB |
Output is correct |
67 |
Correct |
1 ms |
204 KB |
Output is correct |
68 |
Correct |
1 ms |
204 KB |
Output is correct |
69 |
Correct |
4 ms |
296 KB |
Output is correct |
70 |
Correct |
37 ms |
296 KB |
Output is correct |
71 |
Execution timed out |
5037 ms |
720 KB |
Time limit exceeded |
72 |
Halted |
0 ms |
0 KB |
- |