답안 #648431

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
648431 2022-10-06T12:45:21 Z ymm Toys (CEOI18_toy) C++17
100 / 100
3069 ms 90188 KB
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;

set<int> solve(int n)
{
	static map<int, set<int>> mem;
	if (n == 1)
		return {0};
	if (mem.count(n))
		return mem[n];
	set<int> ans;
	for (int x = 2; x*x <= n; ++x) {
		if (n%x)
			continue;
		for (int y : solve(x))
			ans.insert(y+n/x-1);
		for (int y : solve(n/x))
			ans.insert(y+x-1);
	}
	ans.insert(n-1);
	mem[n] = ans;
	return ans;
}

int main()
{
	cin.tie(0) -> sync_with_stdio(false);
	int n;
	cin >> n;
	auto ans = solve(n);
	cout << ans.size() << '\n';
	for (int x : ans)
		cout << x << ' ';
	cout << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 316 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 316 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 320 KB Output is correct
28 Correct 1 ms 316 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 316 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 324 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 324 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 316 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 320 KB Output is correct
28 Correct 1 ms 316 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 316 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 324 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 324 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 320 KB Output is correct
50 Correct 4 ms 596 KB Output is correct
51 Correct 4 ms 596 KB Output is correct
52 Correct 4 ms 596 KB Output is correct
53 Correct 3 ms 468 KB Output is correct
54 Correct 2 ms 468 KB Output is correct
55 Correct 5 ms 724 KB Output is correct
56 Correct 5 ms 700 KB Output is correct
57 Correct 5 ms 580 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 3 ms 468 KB Output is correct
62 Correct 2 ms 340 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 3 ms 468 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 316 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 320 KB Output is correct
28 Correct 1 ms 316 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 316 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 324 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 324 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 320 KB Output is correct
50 Correct 4 ms 596 KB Output is correct
51 Correct 4 ms 596 KB Output is correct
52 Correct 4 ms 596 KB Output is correct
53 Correct 3 ms 468 KB Output is correct
54 Correct 2 ms 468 KB Output is correct
55 Correct 5 ms 724 KB Output is correct
56 Correct 5 ms 700 KB Output is correct
57 Correct 5 ms 580 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 3 ms 468 KB Output is correct
62 Correct 2 ms 340 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 3 ms 468 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 2 ms 340 KB Output is correct
71 Correct 438 ms 19488 KB Output is correct
72 Correct 290 ms 14808 KB Output is correct
73 Correct 453 ms 17320 KB Output is correct
74 Correct 223 ms 11724 KB Output is correct
75 Correct 243 ms 12512 KB Output is correct
76 Correct 680 ms 26192 KB Output is correct
77 Correct 600 ms 22988 KB Output is correct
78 Correct 523 ms 21780 KB Output is correct
79 Correct 591 ms 21040 KB Output is correct
80 Correct 1 ms 212 KB Output is correct
81 Correct 1 ms 320 KB Output is correct
82 Correct 5 ms 724 KB Output is correct
83 Correct 70 ms 3808 KB Output is correct
84 Correct 77 ms 4620 KB Output is correct
85 Correct 18 ms 1588 KB Output is correct
86 Correct 2 ms 340 KB Output is correct
87 Correct 88 ms 5340 KB Output is correct
88 Correct 1 ms 212 KB Output is correct
89 Correct 1 ms 212 KB Output is correct
90 Correct 2 ms 448 KB Output is correct
91 Correct 25 ms 2316 KB Output is correct
92 Correct 105 ms 7008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 316 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 320 KB Output is correct
28 Correct 1 ms 316 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 2 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 316 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 324 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 324 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 320 KB Output is correct
50 Correct 4 ms 596 KB Output is correct
51 Correct 4 ms 596 KB Output is correct
52 Correct 4 ms 596 KB Output is correct
53 Correct 3 ms 468 KB Output is correct
54 Correct 2 ms 468 KB Output is correct
55 Correct 5 ms 724 KB Output is correct
56 Correct 5 ms 700 KB Output is correct
57 Correct 5 ms 580 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 3 ms 468 KB Output is correct
62 Correct 2 ms 340 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 3 ms 468 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 2 ms 340 KB Output is correct
71 Correct 438 ms 19488 KB Output is correct
72 Correct 290 ms 14808 KB Output is correct
73 Correct 453 ms 17320 KB Output is correct
74 Correct 223 ms 11724 KB Output is correct
75 Correct 243 ms 12512 KB Output is correct
76 Correct 680 ms 26192 KB Output is correct
77 Correct 600 ms 22988 KB Output is correct
78 Correct 523 ms 21780 KB Output is correct
79 Correct 591 ms 21040 KB Output is correct
80 Correct 1 ms 212 KB Output is correct
81 Correct 1 ms 320 KB Output is correct
82 Correct 5 ms 724 KB Output is correct
83 Correct 70 ms 3808 KB Output is correct
84 Correct 77 ms 4620 KB Output is correct
85 Correct 18 ms 1588 KB Output is correct
86 Correct 2 ms 340 KB Output is correct
87 Correct 88 ms 5340 KB Output is correct
88 Correct 1 ms 212 KB Output is correct
89 Correct 1 ms 212 KB Output is correct
90 Correct 2 ms 448 KB Output is correct
91 Correct 25 ms 2316 KB Output is correct
92 Correct 105 ms 7008 KB Output is correct
93 Correct 2580 ms 80612 KB Output is correct
94 Correct 1435 ms 54664 KB Output is correct
95 Correct 1640 ms 57252 KB Output is correct
96 Correct 1397 ms 51176 KB Output is correct
97 Correct 1263 ms 46404 KB Output is correct
98 Correct 3069 ms 89116 KB Output is correct
99 Correct 3041 ms 90188 KB Output is correct
100 Correct 2860 ms 86924 KB Output is correct
101 Correct 2727 ms 80504 KB Output is correct
102 Correct 2220 ms 72500 KB Output is correct
103 Correct 1863 ms 65268 KB Output is correct
104 Correct 1 ms 212 KB Output is correct
105 Correct 1 ms 212 KB Output is correct
106 Correct 8 ms 980 KB Output is correct
107 Correct 177 ms 10320 KB Output is correct
108 Correct 480 ms 21700 KB Output is correct
109 Correct 44 ms 3532 KB Output is correct
110 Correct 2 ms 316 KB Output is correct
111 Correct 243 ms 13008 KB Output is correct
112 Correct 1 ms 212 KB Output is correct
113 Correct 1 ms 212 KB Output is correct
114 Correct 8 ms 964 KB Output is correct
115 Correct 1 ms 320 KB Output is correct
116 Correct 18 ms 1916 KB Output is correct
117 Correct 520 ms 26252 KB Output is correct