#include<bits/stdc++.h>
using namespace std;
const int N = 1e7 + 5;
int n;
map<pair<int , int> , bool> visited;
vector<int> Div[N];
vector<int> ans;
void calc(int x)
{
if (x > 1e7) return;
for (int i = 1 ; i * i <= x ; ++i)
{
if (x % i == 0)
{
if (i != 1) Div[x].push_back(i);
if (i * i != x && x / i != 1) Div[x].push_back(x / i);
}
}
}
void build()
{
for (int i = 1 ; i * i <= n ; ++i)
{
if (n % i == 0)
{
calc(i);
if (i * i != n) calc(n / i);
}
}
}
void backtrack(int n , int sum)
{
if (visited[{n , sum}] == true) return;
visited[{n , sum}] = true;
if (n == 1) return;
if (n <= 1e7)
{
for (int x : Div[n]) backtrack(n / x , sum + x - 1);
}
else
{
for (int i = 1 ; i * i <= n ; ++i)
{
if (n % i == 0)
{
if (i != 1) backtrack(n / i , sum + i - 1);
if (i * i != n && n / i != 1) backtrack(i , sum + n / i - 1);
}
}
}
}
int main()
{
// freopen(".inp","r",stdin);
// freopen(".out","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
build();
backtrack(n , 0);
for (auto x : visited)
{
if (x.first.first == 1) ans.push_back(x.first.second);
else break;
}
cout << ans.size() << "\n";
for (int x : ans) cout << x << " ";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
235096 KB |
Output is correct |
2 |
Correct |
112 ms |
235056 KB |
Output is correct |
3 |
Correct |
111 ms |
235120 KB |
Output is correct |
4 |
Correct |
114 ms |
235124 KB |
Output is correct |
5 |
Correct |
142 ms |
235100 KB |
Output is correct |
6 |
Correct |
122 ms |
235092 KB |
Output is correct |
7 |
Correct |
108 ms |
235100 KB |
Output is correct |
8 |
Correct |
110 ms |
235096 KB |
Output is correct |
9 |
Correct |
118 ms |
235052 KB |
Output is correct |
10 |
Correct |
111 ms |
235064 KB |
Output is correct |
11 |
Correct |
110 ms |
235128 KB |
Output is correct |
12 |
Correct |
112 ms |
235096 KB |
Output is correct |
13 |
Correct |
113 ms |
235108 KB |
Output is correct |
14 |
Correct |
118 ms |
235004 KB |
Output is correct |
15 |
Correct |
123 ms |
235068 KB |
Output is correct |
16 |
Correct |
112 ms |
235100 KB |
Output is correct |
17 |
Correct |
111 ms |
235136 KB |
Output is correct |
18 |
Correct |
108 ms |
235132 KB |
Output is correct |
19 |
Correct |
127 ms |
235024 KB |
Output is correct |
20 |
Correct |
110 ms |
235032 KB |
Output is correct |
21 |
Correct |
113 ms |
235120 KB |
Output is correct |
22 |
Correct |
113 ms |
235160 KB |
Output is correct |
23 |
Correct |
115 ms |
235168 KB |
Output is correct |
24 |
Correct |
119 ms |
235128 KB |
Output is correct |
25 |
Correct |
111 ms |
235128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
235096 KB |
Output is correct |
2 |
Correct |
112 ms |
235056 KB |
Output is correct |
3 |
Correct |
111 ms |
235120 KB |
Output is correct |
4 |
Correct |
114 ms |
235124 KB |
Output is correct |
5 |
Correct |
142 ms |
235100 KB |
Output is correct |
6 |
Correct |
122 ms |
235092 KB |
Output is correct |
7 |
Correct |
108 ms |
235100 KB |
Output is correct |
8 |
Correct |
110 ms |
235096 KB |
Output is correct |
9 |
Correct |
118 ms |
235052 KB |
Output is correct |
10 |
Correct |
111 ms |
235064 KB |
Output is correct |
11 |
Correct |
110 ms |
235128 KB |
Output is correct |
12 |
Correct |
112 ms |
235096 KB |
Output is correct |
13 |
Correct |
113 ms |
235108 KB |
Output is correct |
14 |
Correct |
118 ms |
235004 KB |
Output is correct |
15 |
Correct |
123 ms |
235068 KB |
Output is correct |
16 |
Correct |
112 ms |
235100 KB |
Output is correct |
17 |
Correct |
111 ms |
235136 KB |
Output is correct |
18 |
Correct |
108 ms |
235132 KB |
Output is correct |
19 |
Correct |
127 ms |
235024 KB |
Output is correct |
20 |
Correct |
110 ms |
235032 KB |
Output is correct |
21 |
Correct |
113 ms |
235120 KB |
Output is correct |
22 |
Correct |
113 ms |
235160 KB |
Output is correct |
23 |
Correct |
115 ms |
235168 KB |
Output is correct |
24 |
Correct |
119 ms |
235128 KB |
Output is correct |
25 |
Correct |
111 ms |
235128 KB |
Output is correct |
26 |
Correct |
123 ms |
235152 KB |
Output is correct |
27 |
Correct |
125 ms |
235212 KB |
Output is correct |
28 |
Correct |
112 ms |
235096 KB |
Output is correct |
29 |
Correct |
119 ms |
235104 KB |
Output is correct |
30 |
Correct |
107 ms |
235052 KB |
Output is correct |
31 |
Correct |
128 ms |
235204 KB |
Output is correct |
32 |
Correct |
138 ms |
235212 KB |
Output is correct |
33 |
Correct |
119 ms |
235120 KB |
Output is correct |
34 |
Correct |
108 ms |
235076 KB |
Output is correct |
35 |
Correct |
119 ms |
235028 KB |
Output is correct |
36 |
Correct |
125 ms |
235184 KB |
Output is correct |
37 |
Correct |
121 ms |
235076 KB |
Output is correct |
38 |
Correct |
119 ms |
235156 KB |
Output is correct |
39 |
Correct |
115 ms |
235124 KB |
Output is correct |
40 |
Correct |
117 ms |
235132 KB |
Output is correct |
41 |
Correct |
121 ms |
235080 KB |
Output is correct |
42 |
Correct |
112 ms |
235052 KB |
Output is correct |
43 |
Correct |
120 ms |
235136 KB |
Output is correct |
44 |
Correct |
113 ms |
235116 KB |
Output is correct |
45 |
Correct |
120 ms |
235056 KB |
Output is correct |
46 |
Correct |
116 ms |
235204 KB |
Output is correct |
47 |
Correct |
116 ms |
235128 KB |
Output is correct |
48 |
Correct |
117 ms |
235108 KB |
Output is correct |
49 |
Correct |
115 ms |
235100 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
235096 KB |
Output is correct |
2 |
Correct |
112 ms |
235056 KB |
Output is correct |
3 |
Correct |
111 ms |
235120 KB |
Output is correct |
4 |
Correct |
114 ms |
235124 KB |
Output is correct |
5 |
Correct |
142 ms |
235100 KB |
Output is correct |
6 |
Correct |
122 ms |
235092 KB |
Output is correct |
7 |
Correct |
108 ms |
235100 KB |
Output is correct |
8 |
Correct |
110 ms |
235096 KB |
Output is correct |
9 |
Correct |
118 ms |
235052 KB |
Output is correct |
10 |
Correct |
111 ms |
235064 KB |
Output is correct |
11 |
Correct |
110 ms |
235128 KB |
Output is correct |
12 |
Correct |
112 ms |
235096 KB |
Output is correct |
13 |
Correct |
113 ms |
235108 KB |
Output is correct |
14 |
Correct |
118 ms |
235004 KB |
Output is correct |
15 |
Correct |
123 ms |
235068 KB |
Output is correct |
16 |
Correct |
112 ms |
235100 KB |
Output is correct |
17 |
Correct |
111 ms |
235136 KB |
Output is correct |
18 |
Correct |
108 ms |
235132 KB |
Output is correct |
19 |
Correct |
127 ms |
235024 KB |
Output is correct |
20 |
Correct |
110 ms |
235032 KB |
Output is correct |
21 |
Correct |
113 ms |
235120 KB |
Output is correct |
22 |
Correct |
113 ms |
235160 KB |
Output is correct |
23 |
Correct |
115 ms |
235168 KB |
Output is correct |
24 |
Correct |
119 ms |
235128 KB |
Output is correct |
25 |
Correct |
111 ms |
235128 KB |
Output is correct |
26 |
Correct |
123 ms |
235152 KB |
Output is correct |
27 |
Correct |
125 ms |
235212 KB |
Output is correct |
28 |
Correct |
112 ms |
235096 KB |
Output is correct |
29 |
Correct |
119 ms |
235104 KB |
Output is correct |
30 |
Correct |
107 ms |
235052 KB |
Output is correct |
31 |
Correct |
128 ms |
235204 KB |
Output is correct |
32 |
Correct |
138 ms |
235212 KB |
Output is correct |
33 |
Correct |
119 ms |
235120 KB |
Output is correct |
34 |
Correct |
108 ms |
235076 KB |
Output is correct |
35 |
Correct |
119 ms |
235028 KB |
Output is correct |
36 |
Correct |
125 ms |
235184 KB |
Output is correct |
37 |
Correct |
121 ms |
235076 KB |
Output is correct |
38 |
Correct |
119 ms |
235156 KB |
Output is correct |
39 |
Correct |
115 ms |
235124 KB |
Output is correct |
40 |
Correct |
117 ms |
235132 KB |
Output is correct |
41 |
Correct |
121 ms |
235080 KB |
Output is correct |
42 |
Correct |
112 ms |
235052 KB |
Output is correct |
43 |
Correct |
120 ms |
235136 KB |
Output is correct |
44 |
Correct |
113 ms |
235116 KB |
Output is correct |
45 |
Correct |
120 ms |
235056 KB |
Output is correct |
46 |
Correct |
116 ms |
235204 KB |
Output is correct |
47 |
Correct |
116 ms |
235128 KB |
Output is correct |
48 |
Correct |
117 ms |
235108 KB |
Output is correct |
49 |
Correct |
115 ms |
235100 KB |
Output is correct |
50 |
Correct |
124 ms |
235632 KB |
Output is correct |
51 |
Correct |
135 ms |
235424 KB |
Output is correct |
52 |
Correct |
116 ms |
235488 KB |
Output is correct |
53 |
Correct |
113 ms |
235372 KB |
Output is correct |
54 |
Correct |
113 ms |
235236 KB |
Output is correct |
55 |
Correct |
141 ms |
235588 KB |
Output is correct |
56 |
Correct |
131 ms |
235488 KB |
Output is correct |
57 |
Correct |
116 ms |
235460 KB |
Output is correct |
58 |
Correct |
110 ms |
235116 KB |
Output is correct |
59 |
Correct |
112 ms |
235028 KB |
Output is correct |
60 |
Correct |
135 ms |
235296 KB |
Output is correct |
61 |
Correct |
112 ms |
235272 KB |
Output is correct |
62 |
Correct |
112 ms |
235200 KB |
Output is correct |
63 |
Correct |
119 ms |
235204 KB |
Output is correct |
64 |
Correct |
116 ms |
235136 KB |
Output is correct |
65 |
Correct |
115 ms |
235320 KB |
Output is correct |
66 |
Correct |
108 ms |
235084 KB |
Output is correct |
67 |
Correct |
112 ms |
235116 KB |
Output is correct |
68 |
Correct |
109 ms |
235108 KB |
Output is correct |
69 |
Correct |
137 ms |
235048 KB |
Output is correct |
70 |
Correct |
112 ms |
235236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
235096 KB |
Output is correct |
2 |
Correct |
112 ms |
235056 KB |
Output is correct |
3 |
Correct |
111 ms |
235120 KB |
Output is correct |
4 |
Correct |
114 ms |
235124 KB |
Output is correct |
5 |
Correct |
142 ms |
235100 KB |
Output is correct |
6 |
Correct |
122 ms |
235092 KB |
Output is correct |
7 |
Correct |
108 ms |
235100 KB |
Output is correct |
8 |
Correct |
110 ms |
235096 KB |
Output is correct |
9 |
Correct |
118 ms |
235052 KB |
Output is correct |
10 |
Correct |
111 ms |
235064 KB |
Output is correct |
11 |
Correct |
110 ms |
235128 KB |
Output is correct |
12 |
Correct |
112 ms |
235096 KB |
Output is correct |
13 |
Correct |
113 ms |
235108 KB |
Output is correct |
14 |
Correct |
118 ms |
235004 KB |
Output is correct |
15 |
Correct |
123 ms |
235068 KB |
Output is correct |
16 |
Correct |
112 ms |
235100 KB |
Output is correct |
17 |
Correct |
111 ms |
235136 KB |
Output is correct |
18 |
Correct |
108 ms |
235132 KB |
Output is correct |
19 |
Correct |
127 ms |
235024 KB |
Output is correct |
20 |
Correct |
110 ms |
235032 KB |
Output is correct |
21 |
Correct |
113 ms |
235120 KB |
Output is correct |
22 |
Correct |
113 ms |
235160 KB |
Output is correct |
23 |
Correct |
115 ms |
235168 KB |
Output is correct |
24 |
Correct |
119 ms |
235128 KB |
Output is correct |
25 |
Correct |
111 ms |
235128 KB |
Output is correct |
26 |
Correct |
123 ms |
235152 KB |
Output is correct |
27 |
Correct |
125 ms |
235212 KB |
Output is correct |
28 |
Correct |
112 ms |
235096 KB |
Output is correct |
29 |
Correct |
119 ms |
235104 KB |
Output is correct |
30 |
Correct |
107 ms |
235052 KB |
Output is correct |
31 |
Correct |
128 ms |
235204 KB |
Output is correct |
32 |
Correct |
138 ms |
235212 KB |
Output is correct |
33 |
Correct |
119 ms |
235120 KB |
Output is correct |
34 |
Correct |
108 ms |
235076 KB |
Output is correct |
35 |
Correct |
119 ms |
235028 KB |
Output is correct |
36 |
Correct |
125 ms |
235184 KB |
Output is correct |
37 |
Correct |
121 ms |
235076 KB |
Output is correct |
38 |
Correct |
119 ms |
235156 KB |
Output is correct |
39 |
Correct |
115 ms |
235124 KB |
Output is correct |
40 |
Correct |
117 ms |
235132 KB |
Output is correct |
41 |
Correct |
121 ms |
235080 KB |
Output is correct |
42 |
Correct |
112 ms |
235052 KB |
Output is correct |
43 |
Correct |
120 ms |
235136 KB |
Output is correct |
44 |
Correct |
113 ms |
235116 KB |
Output is correct |
45 |
Correct |
120 ms |
235056 KB |
Output is correct |
46 |
Correct |
116 ms |
235204 KB |
Output is correct |
47 |
Correct |
116 ms |
235128 KB |
Output is correct |
48 |
Correct |
117 ms |
235108 KB |
Output is correct |
49 |
Correct |
115 ms |
235100 KB |
Output is correct |
50 |
Correct |
124 ms |
235632 KB |
Output is correct |
51 |
Correct |
135 ms |
235424 KB |
Output is correct |
52 |
Correct |
116 ms |
235488 KB |
Output is correct |
53 |
Correct |
113 ms |
235372 KB |
Output is correct |
54 |
Correct |
113 ms |
235236 KB |
Output is correct |
55 |
Correct |
141 ms |
235588 KB |
Output is correct |
56 |
Correct |
131 ms |
235488 KB |
Output is correct |
57 |
Correct |
116 ms |
235460 KB |
Output is correct |
58 |
Correct |
110 ms |
235116 KB |
Output is correct |
59 |
Correct |
112 ms |
235028 KB |
Output is correct |
60 |
Correct |
135 ms |
235296 KB |
Output is correct |
61 |
Correct |
112 ms |
235272 KB |
Output is correct |
62 |
Correct |
112 ms |
235200 KB |
Output is correct |
63 |
Correct |
119 ms |
235204 KB |
Output is correct |
64 |
Correct |
116 ms |
235136 KB |
Output is correct |
65 |
Correct |
115 ms |
235320 KB |
Output is correct |
66 |
Correct |
108 ms |
235084 KB |
Output is correct |
67 |
Correct |
112 ms |
235116 KB |
Output is correct |
68 |
Correct |
109 ms |
235108 KB |
Output is correct |
69 |
Correct |
137 ms |
235048 KB |
Output is correct |
70 |
Correct |
112 ms |
235236 KB |
Output is correct |
71 |
Correct |
1495 ms |
259812 KB |
Output is correct |
72 |
Correct |
921 ms |
253764 KB |
Output is correct |
73 |
Correct |
1262 ms |
256952 KB |
Output is correct |
74 |
Correct |
664 ms |
249860 KB |
Output is correct |
75 |
Correct |
803 ms |
250932 KB |
Output is correct |
76 |
Runtime error |
1773 ms |
262148 KB |
Execution killed with signal 9 |
77 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
119 ms |
235096 KB |
Output is correct |
2 |
Correct |
112 ms |
235056 KB |
Output is correct |
3 |
Correct |
111 ms |
235120 KB |
Output is correct |
4 |
Correct |
114 ms |
235124 KB |
Output is correct |
5 |
Correct |
142 ms |
235100 KB |
Output is correct |
6 |
Correct |
122 ms |
235092 KB |
Output is correct |
7 |
Correct |
108 ms |
235100 KB |
Output is correct |
8 |
Correct |
110 ms |
235096 KB |
Output is correct |
9 |
Correct |
118 ms |
235052 KB |
Output is correct |
10 |
Correct |
111 ms |
235064 KB |
Output is correct |
11 |
Correct |
110 ms |
235128 KB |
Output is correct |
12 |
Correct |
112 ms |
235096 KB |
Output is correct |
13 |
Correct |
113 ms |
235108 KB |
Output is correct |
14 |
Correct |
118 ms |
235004 KB |
Output is correct |
15 |
Correct |
123 ms |
235068 KB |
Output is correct |
16 |
Correct |
112 ms |
235100 KB |
Output is correct |
17 |
Correct |
111 ms |
235136 KB |
Output is correct |
18 |
Correct |
108 ms |
235132 KB |
Output is correct |
19 |
Correct |
127 ms |
235024 KB |
Output is correct |
20 |
Correct |
110 ms |
235032 KB |
Output is correct |
21 |
Correct |
113 ms |
235120 KB |
Output is correct |
22 |
Correct |
113 ms |
235160 KB |
Output is correct |
23 |
Correct |
115 ms |
235168 KB |
Output is correct |
24 |
Correct |
119 ms |
235128 KB |
Output is correct |
25 |
Correct |
111 ms |
235128 KB |
Output is correct |
26 |
Correct |
123 ms |
235152 KB |
Output is correct |
27 |
Correct |
125 ms |
235212 KB |
Output is correct |
28 |
Correct |
112 ms |
235096 KB |
Output is correct |
29 |
Correct |
119 ms |
235104 KB |
Output is correct |
30 |
Correct |
107 ms |
235052 KB |
Output is correct |
31 |
Correct |
128 ms |
235204 KB |
Output is correct |
32 |
Correct |
138 ms |
235212 KB |
Output is correct |
33 |
Correct |
119 ms |
235120 KB |
Output is correct |
34 |
Correct |
108 ms |
235076 KB |
Output is correct |
35 |
Correct |
119 ms |
235028 KB |
Output is correct |
36 |
Correct |
125 ms |
235184 KB |
Output is correct |
37 |
Correct |
121 ms |
235076 KB |
Output is correct |
38 |
Correct |
119 ms |
235156 KB |
Output is correct |
39 |
Correct |
115 ms |
235124 KB |
Output is correct |
40 |
Correct |
117 ms |
235132 KB |
Output is correct |
41 |
Correct |
121 ms |
235080 KB |
Output is correct |
42 |
Correct |
112 ms |
235052 KB |
Output is correct |
43 |
Correct |
120 ms |
235136 KB |
Output is correct |
44 |
Correct |
113 ms |
235116 KB |
Output is correct |
45 |
Correct |
120 ms |
235056 KB |
Output is correct |
46 |
Correct |
116 ms |
235204 KB |
Output is correct |
47 |
Correct |
116 ms |
235128 KB |
Output is correct |
48 |
Correct |
117 ms |
235108 KB |
Output is correct |
49 |
Correct |
115 ms |
235100 KB |
Output is correct |
50 |
Correct |
124 ms |
235632 KB |
Output is correct |
51 |
Correct |
135 ms |
235424 KB |
Output is correct |
52 |
Correct |
116 ms |
235488 KB |
Output is correct |
53 |
Correct |
113 ms |
235372 KB |
Output is correct |
54 |
Correct |
113 ms |
235236 KB |
Output is correct |
55 |
Correct |
141 ms |
235588 KB |
Output is correct |
56 |
Correct |
131 ms |
235488 KB |
Output is correct |
57 |
Correct |
116 ms |
235460 KB |
Output is correct |
58 |
Correct |
110 ms |
235116 KB |
Output is correct |
59 |
Correct |
112 ms |
235028 KB |
Output is correct |
60 |
Correct |
135 ms |
235296 KB |
Output is correct |
61 |
Correct |
112 ms |
235272 KB |
Output is correct |
62 |
Correct |
112 ms |
235200 KB |
Output is correct |
63 |
Correct |
119 ms |
235204 KB |
Output is correct |
64 |
Correct |
116 ms |
235136 KB |
Output is correct |
65 |
Correct |
115 ms |
235320 KB |
Output is correct |
66 |
Correct |
108 ms |
235084 KB |
Output is correct |
67 |
Correct |
112 ms |
235116 KB |
Output is correct |
68 |
Correct |
109 ms |
235108 KB |
Output is correct |
69 |
Correct |
137 ms |
235048 KB |
Output is correct |
70 |
Correct |
112 ms |
235236 KB |
Output is correct |
71 |
Correct |
1495 ms |
259812 KB |
Output is correct |
72 |
Correct |
921 ms |
253764 KB |
Output is correct |
73 |
Correct |
1262 ms |
256952 KB |
Output is correct |
74 |
Correct |
664 ms |
249860 KB |
Output is correct |
75 |
Correct |
803 ms |
250932 KB |
Output is correct |
76 |
Runtime error |
1773 ms |
262148 KB |
Execution killed with signal 9 |
77 |
Halted |
0 ms |
0 KB |
- |