Submission #528963

# Submission time Handle Problem Language Result Execution time Memory
528963 2022-02-21T20:45:06 Z LucaDantas Toys (CEOI18_toy) C++17
100 / 100
1818 ms 4420 KB
#include <bits/stdc++.h>
using namespace std;

constexpr int maxn = 1e5+10;

int f[maxn];

void sieve() {
	for(int i = 0; i < maxn; i++) {
		if(!f[i]) {
			f[i] = i;
			for(int j = i*i; j < maxn; j += i)
				f[i] = i;
		}
	}
}

vector<int> dv(int x) {
	vector<int> ans;
	for(int i = 2; i*i <= x; i++)
		if(x % i == 0) ans.push_back(i), ans.push_back(x / i);
	if(ans.size() >= 2 && ans[ans.size() - 2] * ans[ans.size() - 2] == x)
		ans.pop_back();
	ans.push_back(x);
	sort(ans.begin(), ans.end(), greater<int>());
	return ans;
}

set<int> mark;

void brute(int val, int soma, vector<int> d2) {
	// printf("%d\n", val); fflush(stdout);
	if(val == 1) return (void)(mark.insert(soma));
	vector<int> d;
	while(d2.size()) {
		if(val % d2.back() == 0) d.push_back(d2.back());
		d2.pop_back();
	}
	while(d.size()) {
		// printf("%d\n", d.back());
		brute(val / d.back(), soma + d.back() - 1, d);
		d.pop_back();
	}
}

int main() {
	int n; scanf("%d", &n);
	brute(n, 0, dv(n));
	printf("%ld\n", mark.size());
	for(int x : mark)
		printf("%d ", x);
	puts("");
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |  int n; scanf("%d", &n);
      |         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 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 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 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 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 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 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 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 0 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 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 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 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 0 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 2 ms 332 KB Output is correct
56 Correct 2 ms 336 KB Output is correct
57 Correct 2 ms 332 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 1 ms 204 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 1 ms 316 KB Output is correct
63 Correct 1 ms 204 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 1 ms 204 KB Output is correct
66 Correct 0 ms 204 KB Output is correct
67 Correct 0 ms 204 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 0 ms 204 KB Output is correct
70 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 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 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 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 0 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 2 ms 332 KB Output is correct
56 Correct 2 ms 336 KB Output is correct
57 Correct 2 ms 332 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 1 ms 204 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 1 ms 316 KB Output is correct
63 Correct 1 ms 204 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 1 ms 204 KB Output is correct
66 Correct 0 ms 204 KB Output is correct
67 Correct 0 ms 204 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 0 ms 204 KB Output is correct
70 Correct 1 ms 204 KB Output is correct
71 Correct 143 ms 1440 KB Output is correct
72 Correct 89 ms 1188 KB Output is correct
73 Correct 177 ms 1176 KB Output is correct
74 Correct 67 ms 988 KB Output is correct
75 Correct 95 ms 1004 KB Output is correct
76 Correct 316 ms 1604 KB Output is correct
77 Correct 386 ms 1456 KB Output is correct
78 Correct 241 ms 1420 KB Output is correct
79 Correct 257 ms 1568 KB Output is correct
80 Correct 1 ms 204 KB Output is correct
81 Correct 0 ms 204 KB Output is correct
82 Correct 2 ms 332 KB Output is correct
83 Correct 31 ms 612 KB Output is correct
84 Correct 30 ms 696 KB Output is correct
85 Correct 5 ms 460 KB Output is correct
86 Correct 1 ms 204 KB Output is correct
87 Correct 28 ms 732 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 296 KB Output is correct
91 Correct 7 ms 560 KB Output is correct
92 Correct 28 ms 944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 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 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 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 0 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 2 ms 332 KB Output is correct
56 Correct 2 ms 336 KB Output is correct
57 Correct 2 ms 332 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 1 ms 204 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 1 ms 316 KB Output is correct
63 Correct 1 ms 204 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 1 ms 204 KB Output is correct
66 Correct 0 ms 204 KB Output is correct
67 Correct 0 ms 204 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 0 ms 204 KB Output is correct
70 Correct 1 ms 204 KB Output is correct
71 Correct 143 ms 1440 KB Output is correct
72 Correct 89 ms 1188 KB Output is correct
73 Correct 177 ms 1176 KB Output is correct
74 Correct 67 ms 988 KB Output is correct
75 Correct 95 ms 1004 KB Output is correct
76 Correct 316 ms 1604 KB Output is correct
77 Correct 386 ms 1456 KB Output is correct
78 Correct 241 ms 1420 KB Output is correct
79 Correct 257 ms 1568 KB Output is correct
80 Correct 1 ms 204 KB Output is correct
81 Correct 0 ms 204 KB Output is correct
82 Correct 2 ms 332 KB Output is correct
83 Correct 31 ms 612 KB Output is correct
84 Correct 30 ms 696 KB Output is correct
85 Correct 5 ms 460 KB Output is correct
86 Correct 1 ms 204 KB Output is correct
87 Correct 28 ms 732 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 296 KB Output is correct
91 Correct 7 ms 560 KB Output is correct
92 Correct 28 ms 944 KB Output is correct
93 Correct 1169 ms 4020 KB Output is correct
94 Correct 426 ms 3236 KB Output is correct
95 Correct 634 ms 3236 KB Output is correct
96 Correct 557 ms 2884 KB Output is correct
97 Correct 542 ms 2628 KB Output is correct
98 Correct 1410 ms 4420 KB Output is correct
99 Correct 1727 ms 4344 KB Output is correct
100 Correct 1440 ms 4352 KB Output is correct
101 Correct 1818 ms 4072 KB Output is correct
102 Correct 1564 ms 3788 KB Output is correct
103 Correct 751 ms 3668 KB Output is correct
104 Correct 1 ms 304 KB Output is correct
105 Correct 1 ms 204 KB Output is correct
106 Correct 3 ms 332 KB Output is correct
107 Correct 123 ms 1148 KB Output is correct
108 Correct 253 ms 1836 KB Output is correct
109 Correct 12 ms 716 KB Output is correct
110 Correct 1 ms 204 KB Output is correct
111 Correct 90 ms 1380 KB Output is correct
112 Correct 1 ms 300 KB Output is correct
113 Correct 1 ms 204 KB Output is correct
114 Correct 2 ms 332 KB Output is correct
115 Correct 1 ms 204 KB Output is correct
116 Correct 5 ms 460 KB Output is correct
117 Correct 118 ms 2280 KB Output is correct