답안 #470912

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
470912 2021-09-06T07:51:34 Z prvocislo Toys (CEOI18_toy) C++17
100 / 100
1108 ms 83648 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

void divisors(int n, vector<int> &di)
{
	for (int i = 1; i * i <= n; i++) if (n % i == 0)
	{
		di.push_back(i);
		if (n / i != i) di.push_back(n / i);
	}
	sort(di.begin(), di.end());
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	if (n == 1)
	{
		cout << "1\n0\n";
		return 0;
	}
	vector<int> v;
	divisors(n, v);
	int k = v.size();
	vector<vector<int> > d(v.size());
	for (int i = 0; i < v.size(); i++)
	{
		divisors(v[i], d[i]);
		for (int j = 0; j < d[i].size(); j++) d[i][j] = lower_bound(v.begin(), v.end(), d[i][j]) - v.begin();
	}
	vector<vector<int> > mul(k, vector<int>(k, -1));
	for (int i = 0; i < k; i++) for (int j : d[k - 1 - i])
	{
		int x = v[i] * v[j];
		mul[i][j] = lower_bound(v.begin(), v.end(), x) - v.begin();
	}
	vector<set<int> > dp(k);
	dp[0].insert(0);
	set<int> ans;
	for (int i = 1; i < k; i++)
	{
		if (i <= (k - 1) / 2)
		{
			for (int m : d[k - 1 - i])
			{
				for (int s : dp[m])
				{
					dp[mul[i][m]].insert(s + v[i] - 1);
				}
			}
		}
		for (int s : dp[k - 1 - i])
		{
			ans.insert(s + v[i] - 1);
		}
	}
	cout << ans.size() << "\n";
	for (int i : ans) cout << i << " ";
	cout << "\n";
	return 0;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  for (int i = 0; i < v.size(); i++)
      |                  ~~^~~~~~~~~~
toy.cpp:36:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |   for (int j = 0; j < d[i].size(); j++) d[i][j] = lower_bound(v.begin(), v.end(), d[i][j]) - v.begin();
      |                   ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 280 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 316 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 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 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 280 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 316 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 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 1 ms 204 KB Output is correct
23 Correct 1 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 1 ms 332 KB Output is correct
27 Correct 1 ms 308 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 308 KB Output is correct
31 Correct 1 ms 304 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 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 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 332 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 0 ms 204 KB Output is correct
45 Correct 1 ms 312 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 280 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 316 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 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 1 ms 204 KB Output is correct
23 Correct 1 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 1 ms 332 KB Output is correct
27 Correct 1 ms 308 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 308 KB Output is correct
31 Correct 1 ms 304 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 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 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 332 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 0 ms 204 KB Output is correct
45 Correct 1 ms 312 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 312 KB Output is correct
50 Correct 2 ms 588 KB Output is correct
51 Correct 2 ms 588 KB Output is correct
52 Correct 2 ms 588 KB Output is correct
53 Correct 2 ms 460 KB Output is correct
54 Correct 1 ms 440 KB Output is correct
55 Correct 3 ms 716 KB Output is correct
56 Correct 2 ms 588 KB Output is correct
57 Correct 4 ms 572 KB Output is correct
58 Correct 1 ms 204 KB Output is correct
59 Correct 1 ms 204 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 1 ms 460 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 1 ms 204 KB Output is correct
65 Correct 1 ms 460 KB Output is correct
66 Correct 1 ms 308 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 280 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 316 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 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 1 ms 204 KB Output is correct
23 Correct 1 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 1 ms 332 KB Output is correct
27 Correct 1 ms 308 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 308 KB Output is correct
31 Correct 1 ms 304 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 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 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 332 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 0 ms 204 KB Output is correct
45 Correct 1 ms 312 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 312 KB Output is correct
50 Correct 2 ms 588 KB Output is correct
51 Correct 2 ms 588 KB Output is correct
52 Correct 2 ms 588 KB Output is correct
53 Correct 2 ms 460 KB Output is correct
54 Correct 1 ms 440 KB Output is correct
55 Correct 3 ms 716 KB Output is correct
56 Correct 2 ms 588 KB Output is correct
57 Correct 4 ms 572 KB Output is correct
58 Correct 1 ms 204 KB Output is correct
59 Correct 1 ms 204 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 1 ms 460 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 1 ms 204 KB Output is correct
65 Correct 1 ms 460 KB Output is correct
66 Correct 1 ms 308 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 1 ms 332 KB Output is correct
71 Correct 148 ms 18952 KB Output is correct
72 Correct 107 ms 14860 KB Output is correct
73 Correct 139 ms 16456 KB Output is correct
74 Correct 80 ms 11724 KB Output is correct
75 Correct 99 ms 12128 KB Output is correct
76 Correct 225 ms 24528 KB Output is correct
77 Correct 185 ms 20848 KB Output is correct
78 Correct 193 ms 20228 KB Output is correct
79 Correct 171 ms 19468 KB Output is correct
80 Correct 1 ms 204 KB Output is correct
81 Correct 1 ms 308 KB Output is correct
82 Correct 2 ms 588 KB Output is correct
83 Correct 19 ms 3488 KB Output is correct
84 Correct 26 ms 4148 KB Output is correct
85 Correct 8 ms 1484 KB Output is correct
86 Correct 1 ms 332 KB Output is correct
87 Correct 31 ms 4748 KB Output is correct
88 Correct 1 ms 204 KB Output is correct
89 Correct 1 ms 204 KB Output is correct
90 Correct 1 ms 332 KB Output is correct
91 Correct 11 ms 2252 KB Output is correct
92 Correct 45 ms 7552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 280 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 316 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 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 1 ms 204 KB Output is correct
23 Correct 1 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 1 ms 332 KB Output is correct
27 Correct 1 ms 308 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 308 KB Output is correct
31 Correct 1 ms 304 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 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 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 332 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 0 ms 204 KB Output is correct
45 Correct 1 ms 312 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 312 KB Output is correct
50 Correct 2 ms 588 KB Output is correct
51 Correct 2 ms 588 KB Output is correct
52 Correct 2 ms 588 KB Output is correct
53 Correct 2 ms 460 KB Output is correct
54 Correct 1 ms 440 KB Output is correct
55 Correct 3 ms 716 KB Output is correct
56 Correct 2 ms 588 KB Output is correct
57 Correct 4 ms 572 KB Output is correct
58 Correct 1 ms 204 KB Output is correct
59 Correct 1 ms 204 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 1 ms 460 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 1 ms 204 KB Output is correct
65 Correct 1 ms 460 KB Output is correct
66 Correct 1 ms 308 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 1 ms 332 KB Output is correct
71 Correct 148 ms 18952 KB Output is correct
72 Correct 107 ms 14860 KB Output is correct
73 Correct 139 ms 16456 KB Output is correct
74 Correct 80 ms 11724 KB Output is correct
75 Correct 99 ms 12128 KB Output is correct
76 Correct 225 ms 24528 KB Output is correct
77 Correct 185 ms 20848 KB Output is correct
78 Correct 193 ms 20228 KB Output is correct
79 Correct 171 ms 19468 KB Output is correct
80 Correct 1 ms 204 KB Output is correct
81 Correct 1 ms 308 KB Output is correct
82 Correct 2 ms 588 KB Output is correct
83 Correct 19 ms 3488 KB Output is correct
84 Correct 26 ms 4148 KB Output is correct
85 Correct 8 ms 1484 KB Output is correct
86 Correct 1 ms 332 KB Output is correct
87 Correct 31 ms 4748 KB Output is correct
88 Correct 1 ms 204 KB Output is correct
89 Correct 1 ms 204 KB Output is correct
90 Correct 1 ms 332 KB Output is correct
91 Correct 11 ms 2252 KB Output is correct
92 Correct 45 ms 7552 KB Output is correct
93 Correct 861 ms 76376 KB Output is correct
94 Correct 490 ms 54004 KB Output is correct
95 Correct 554 ms 55104 KB Output is correct
96 Correct 481 ms 49216 KB Output is correct
97 Correct 428 ms 43964 KB Output is correct
98 Correct 1108 ms 82928 KB Output is correct
99 Correct 1095 ms 83648 KB Output is correct
100 Correct 1014 ms 81036 KB Output is correct
101 Correct 867 ms 72796 KB Output is correct
102 Correct 727 ms 65620 KB Output is correct
103 Correct 611 ms 61060 KB Output is correct
104 Correct 1 ms 204 KB Output is correct
105 Correct 1 ms 204 KB Output is correct
106 Correct 4 ms 844 KB Output is correct
107 Correct 57 ms 9136 KB Output is correct
108 Correct 140 ms 19008 KB Output is correct
109 Correct 16 ms 3252 KB Output is correct
110 Correct 2 ms 204 KB Output is correct
111 Correct 70 ms 11444 KB Output is correct
112 Correct 2 ms 308 KB Output is correct
113 Correct 1 ms 204 KB Output is correct
114 Correct 6 ms 972 KB Output is correct
115 Correct 1 ms 204 KB Output is correct
116 Correct 9 ms 1668 KB Output is correct
117 Correct 189 ms 27400 KB Output is correct