답안 #70509

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70509 2018-08-23T04:56:35 Z 아기상수(#2194) Toys (CEOI18_toy) C++11
100 / 100
1604 ms 110400 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ldouble;

vector <pii> V;
vector <int> L;

void dfs(int x, int y = 1) {
	if(x == szz(V)) { L.pb(y); return; }
	rep(i, V[x].Se + 1) {
		dfs(x + 1, y);
		y = y * V[x].Fi;
	}
}

vector <int> ans[1550];

int main() {
	int n; scanf("%d", &n);
	if(n == 1) {
		puts("1\n0");
		return 0;
	}
	int tn = n;
	for(int i=2;i*i<=tn;i++) {
		if(tn % i != 0) continue;
		int cnt = 0;
		while(tn % i == 0) ++cnt, tn /= i;
		V.emplace_back(i, cnt);
	}
	if(tn > 1) V.emplace_back(tn, 1);
	dfs(0);
	sort(all(L));
	for(int i=1;i<szz(L);i++) {
		ans[i].pb(L[i] - 1);
		for(int j=1;j<i;j++) if(L[i] % L[j] == 0) {
			int k = (int)(lower_bound(all(L), L[i] / L[j]) - L.begin());
			for(int e : ans[k]) ans[i].pb(e + L[j] - 1);
		}
		sort(all(ans[i]));
		ans[i].resize(unique(all(ans[i])) - ans[i].begin());
	}
	printf("%d\n", szz(ans[szz(L)-1]));
	for(int e : ans[szz(L)-1]) printf("%d ", e); puts("");
	return 0;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:71:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(int e : ans[szz(L)-1]) printf("%d ", e); puts("");
  ^~~
toy.cpp:71:47: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(int e : ans[szz(L)-1]) printf("%d ", e); puts("");
                                               ^~~~
toy.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n; scanf("%d", &n);
         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 440 KB Output is correct
3 Correct 2 ms 444 KB Output is correct
4 Correct 2 ms 524 KB Output is correct
5 Correct 3 ms 524 KB Output is correct
6 Correct 2 ms 524 KB Output is correct
7 Correct 3 ms 552 KB Output is correct
8 Correct 3 ms 552 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 3 ms 652 KB Output is correct
11 Correct 3 ms 652 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 3 ms 652 KB Output is correct
14 Correct 3 ms 652 KB Output is correct
15 Correct 2 ms 652 KB Output is correct
16 Correct 3 ms 652 KB Output is correct
17 Correct 3 ms 652 KB Output is correct
18 Correct 3 ms 652 KB Output is correct
19 Correct 3 ms 652 KB Output is correct
20 Correct 2 ms 652 KB Output is correct
21 Correct 3 ms 652 KB Output is correct
22 Correct 3 ms 652 KB Output is correct
23 Correct 2 ms 652 KB Output is correct
24 Correct 3 ms 652 KB Output is correct
25 Correct 2 ms 652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 440 KB Output is correct
3 Correct 2 ms 444 KB Output is correct
4 Correct 2 ms 524 KB Output is correct
5 Correct 3 ms 524 KB Output is correct
6 Correct 2 ms 524 KB Output is correct
7 Correct 3 ms 552 KB Output is correct
8 Correct 3 ms 552 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 3 ms 652 KB Output is correct
11 Correct 3 ms 652 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 3 ms 652 KB Output is correct
14 Correct 3 ms 652 KB Output is correct
15 Correct 2 ms 652 KB Output is correct
16 Correct 3 ms 652 KB Output is correct
17 Correct 3 ms 652 KB Output is correct
18 Correct 3 ms 652 KB Output is correct
19 Correct 3 ms 652 KB Output is correct
20 Correct 2 ms 652 KB Output is correct
21 Correct 3 ms 652 KB Output is correct
22 Correct 3 ms 652 KB Output is correct
23 Correct 2 ms 652 KB Output is correct
24 Correct 3 ms 652 KB Output is correct
25 Correct 2 ms 652 KB Output is correct
26 Correct 4 ms 652 KB Output is correct
27 Correct 3 ms 652 KB Output is correct
28 Correct 3 ms 652 KB Output is correct
29 Correct 3 ms 652 KB Output is correct
30 Correct 2 ms 652 KB Output is correct
31 Correct 3 ms 652 KB Output is correct
32 Correct 3 ms 668 KB Output is correct
33 Correct 3 ms 668 KB Output is correct
34 Correct 3 ms 668 KB Output is correct
35 Correct 3 ms 668 KB Output is correct
36 Correct 3 ms 668 KB Output is correct
37 Correct 3 ms 668 KB Output is correct
38 Correct 4 ms 668 KB Output is correct
39 Correct 3 ms 668 KB Output is correct
40 Correct 2 ms 668 KB Output is correct
41 Correct 2 ms 668 KB Output is correct
42 Correct 3 ms 668 KB Output is correct
43 Correct 3 ms 712 KB Output is correct
44 Correct 2 ms 712 KB Output is correct
45 Correct 3 ms 712 KB Output is correct
46 Correct 3 ms 712 KB Output is correct
47 Correct 2 ms 712 KB Output is correct
48 Correct 3 ms 712 KB Output is correct
49 Correct 3 ms 712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 440 KB Output is correct
3 Correct 2 ms 444 KB Output is correct
4 Correct 2 ms 524 KB Output is correct
5 Correct 3 ms 524 KB Output is correct
6 Correct 2 ms 524 KB Output is correct
7 Correct 3 ms 552 KB Output is correct
8 Correct 3 ms 552 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 3 ms 652 KB Output is correct
11 Correct 3 ms 652 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 3 ms 652 KB Output is correct
14 Correct 3 ms 652 KB Output is correct
15 Correct 2 ms 652 KB Output is correct
16 Correct 3 ms 652 KB Output is correct
17 Correct 3 ms 652 KB Output is correct
18 Correct 3 ms 652 KB Output is correct
19 Correct 3 ms 652 KB Output is correct
20 Correct 2 ms 652 KB Output is correct
21 Correct 3 ms 652 KB Output is correct
22 Correct 3 ms 652 KB Output is correct
23 Correct 2 ms 652 KB Output is correct
24 Correct 3 ms 652 KB Output is correct
25 Correct 2 ms 652 KB Output is correct
26 Correct 4 ms 652 KB Output is correct
27 Correct 3 ms 652 KB Output is correct
28 Correct 3 ms 652 KB Output is correct
29 Correct 3 ms 652 KB Output is correct
30 Correct 2 ms 652 KB Output is correct
31 Correct 3 ms 652 KB Output is correct
32 Correct 3 ms 668 KB Output is correct
33 Correct 3 ms 668 KB Output is correct
34 Correct 3 ms 668 KB Output is correct
35 Correct 3 ms 668 KB Output is correct
36 Correct 3 ms 668 KB Output is correct
37 Correct 3 ms 668 KB Output is correct
38 Correct 4 ms 668 KB Output is correct
39 Correct 3 ms 668 KB Output is correct
40 Correct 2 ms 668 KB Output is correct
41 Correct 2 ms 668 KB Output is correct
42 Correct 3 ms 668 KB Output is correct
43 Correct 3 ms 712 KB Output is correct
44 Correct 2 ms 712 KB Output is correct
45 Correct 3 ms 712 KB Output is correct
46 Correct 3 ms 712 KB Output is correct
47 Correct 2 ms 712 KB Output is correct
48 Correct 3 ms 712 KB Output is correct
49 Correct 3 ms 712 KB Output is correct
50 Correct 4 ms 748 KB Output is correct
51 Correct 4 ms 748 KB Output is correct
52 Correct 4 ms 876 KB Output is correct
53 Correct 5 ms 876 KB Output is correct
54 Correct 3 ms 876 KB Output is correct
55 Correct 5 ms 892 KB Output is correct
56 Correct 6 ms 892 KB Output is correct
57 Correct 5 ms 892 KB Output is correct
58 Correct 2 ms 892 KB Output is correct
59 Correct 3 ms 892 KB Output is correct
60 Correct 2 ms 892 KB Output is correct
61 Correct 4 ms 892 KB Output is correct
62 Correct 4 ms 892 KB Output is correct
63 Correct 3 ms 892 KB Output is correct
64 Correct 2 ms 892 KB Output is correct
65 Correct 4 ms 892 KB Output is correct
66 Correct 2 ms 892 KB Output is correct
67 Correct 2 ms 892 KB Output is correct
68 Correct 2 ms 892 KB Output is correct
69 Correct 2 ms 892 KB Output is correct
70 Correct 3 ms 892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 440 KB Output is correct
3 Correct 2 ms 444 KB Output is correct
4 Correct 2 ms 524 KB Output is correct
5 Correct 3 ms 524 KB Output is correct
6 Correct 2 ms 524 KB Output is correct
7 Correct 3 ms 552 KB Output is correct
8 Correct 3 ms 552 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 3 ms 652 KB Output is correct
11 Correct 3 ms 652 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 3 ms 652 KB Output is correct
14 Correct 3 ms 652 KB Output is correct
15 Correct 2 ms 652 KB Output is correct
16 Correct 3 ms 652 KB Output is correct
17 Correct 3 ms 652 KB Output is correct
18 Correct 3 ms 652 KB Output is correct
19 Correct 3 ms 652 KB Output is correct
20 Correct 2 ms 652 KB Output is correct
21 Correct 3 ms 652 KB Output is correct
22 Correct 3 ms 652 KB Output is correct
23 Correct 2 ms 652 KB Output is correct
24 Correct 3 ms 652 KB Output is correct
25 Correct 2 ms 652 KB Output is correct
26 Correct 4 ms 652 KB Output is correct
27 Correct 3 ms 652 KB Output is correct
28 Correct 3 ms 652 KB Output is correct
29 Correct 3 ms 652 KB Output is correct
30 Correct 2 ms 652 KB Output is correct
31 Correct 3 ms 652 KB Output is correct
32 Correct 3 ms 668 KB Output is correct
33 Correct 3 ms 668 KB Output is correct
34 Correct 3 ms 668 KB Output is correct
35 Correct 3 ms 668 KB Output is correct
36 Correct 3 ms 668 KB Output is correct
37 Correct 3 ms 668 KB Output is correct
38 Correct 4 ms 668 KB Output is correct
39 Correct 3 ms 668 KB Output is correct
40 Correct 2 ms 668 KB Output is correct
41 Correct 2 ms 668 KB Output is correct
42 Correct 3 ms 668 KB Output is correct
43 Correct 3 ms 712 KB Output is correct
44 Correct 2 ms 712 KB Output is correct
45 Correct 3 ms 712 KB Output is correct
46 Correct 3 ms 712 KB Output is correct
47 Correct 2 ms 712 KB Output is correct
48 Correct 3 ms 712 KB Output is correct
49 Correct 3 ms 712 KB Output is correct
50 Correct 4 ms 748 KB Output is correct
51 Correct 4 ms 748 KB Output is correct
52 Correct 4 ms 876 KB Output is correct
53 Correct 5 ms 876 KB Output is correct
54 Correct 3 ms 876 KB Output is correct
55 Correct 5 ms 892 KB Output is correct
56 Correct 6 ms 892 KB Output is correct
57 Correct 5 ms 892 KB Output is correct
58 Correct 2 ms 892 KB Output is correct
59 Correct 3 ms 892 KB Output is correct
60 Correct 2 ms 892 KB Output is correct
61 Correct 4 ms 892 KB Output is correct
62 Correct 4 ms 892 KB Output is correct
63 Correct 3 ms 892 KB Output is correct
64 Correct 2 ms 892 KB Output is correct
65 Correct 4 ms 892 KB Output is correct
66 Correct 2 ms 892 KB Output is correct
67 Correct 2 ms 892 KB Output is correct
68 Correct 2 ms 892 KB Output is correct
69 Correct 2 ms 892 KB Output is correct
70 Correct 3 ms 892 KB Output is correct
71 Correct 226 ms 18188 KB Output is correct
72 Correct 174 ms 18188 KB Output is correct
73 Correct 235 ms 18188 KB Output is correct
74 Correct 121 ms 18188 KB Output is correct
75 Correct 139 ms 18188 KB Output is correct
76 Correct 425 ms 27348 KB Output is correct
77 Correct 329 ms 27348 KB Output is correct
78 Correct 303 ms 27348 KB Output is correct
79 Correct 285 ms 27348 KB Output is correct
80 Correct 2 ms 27348 KB Output is correct
81 Correct 2 ms 27348 KB Output is correct
82 Correct 4 ms 27348 KB Output is correct
83 Correct 35 ms 27348 KB Output is correct
84 Correct 44 ms 27348 KB Output is correct
85 Correct 10 ms 27348 KB Output is correct
86 Correct 2 ms 27348 KB Output is correct
87 Correct 51 ms 27348 KB Output is correct
88 Correct 3 ms 27348 KB Output is correct
89 Correct 3 ms 27348 KB Output is correct
90 Correct 3 ms 27348 KB Output is correct
91 Correct 15 ms 27348 KB Output is correct
92 Correct 59 ms 27348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 440 KB Output is correct
3 Correct 2 ms 444 KB Output is correct
4 Correct 2 ms 524 KB Output is correct
5 Correct 3 ms 524 KB Output is correct
6 Correct 2 ms 524 KB Output is correct
7 Correct 3 ms 552 KB Output is correct
8 Correct 3 ms 552 KB Output is correct
9 Correct 2 ms 652 KB Output is correct
10 Correct 3 ms 652 KB Output is correct
11 Correct 3 ms 652 KB Output is correct
12 Correct 2 ms 652 KB Output is correct
13 Correct 3 ms 652 KB Output is correct
14 Correct 3 ms 652 KB Output is correct
15 Correct 2 ms 652 KB Output is correct
16 Correct 3 ms 652 KB Output is correct
17 Correct 3 ms 652 KB Output is correct
18 Correct 3 ms 652 KB Output is correct
19 Correct 3 ms 652 KB Output is correct
20 Correct 2 ms 652 KB Output is correct
21 Correct 3 ms 652 KB Output is correct
22 Correct 3 ms 652 KB Output is correct
23 Correct 2 ms 652 KB Output is correct
24 Correct 3 ms 652 KB Output is correct
25 Correct 2 ms 652 KB Output is correct
26 Correct 4 ms 652 KB Output is correct
27 Correct 3 ms 652 KB Output is correct
28 Correct 3 ms 652 KB Output is correct
29 Correct 3 ms 652 KB Output is correct
30 Correct 2 ms 652 KB Output is correct
31 Correct 3 ms 652 KB Output is correct
32 Correct 3 ms 668 KB Output is correct
33 Correct 3 ms 668 KB Output is correct
34 Correct 3 ms 668 KB Output is correct
35 Correct 3 ms 668 KB Output is correct
36 Correct 3 ms 668 KB Output is correct
37 Correct 3 ms 668 KB Output is correct
38 Correct 4 ms 668 KB Output is correct
39 Correct 3 ms 668 KB Output is correct
40 Correct 2 ms 668 KB Output is correct
41 Correct 2 ms 668 KB Output is correct
42 Correct 3 ms 668 KB Output is correct
43 Correct 3 ms 712 KB Output is correct
44 Correct 2 ms 712 KB Output is correct
45 Correct 3 ms 712 KB Output is correct
46 Correct 3 ms 712 KB Output is correct
47 Correct 2 ms 712 KB Output is correct
48 Correct 3 ms 712 KB Output is correct
49 Correct 3 ms 712 KB Output is correct
50 Correct 4 ms 748 KB Output is correct
51 Correct 4 ms 748 KB Output is correct
52 Correct 4 ms 876 KB Output is correct
53 Correct 5 ms 876 KB Output is correct
54 Correct 3 ms 876 KB Output is correct
55 Correct 5 ms 892 KB Output is correct
56 Correct 6 ms 892 KB Output is correct
57 Correct 5 ms 892 KB Output is correct
58 Correct 2 ms 892 KB Output is correct
59 Correct 3 ms 892 KB Output is correct
60 Correct 2 ms 892 KB Output is correct
61 Correct 4 ms 892 KB Output is correct
62 Correct 4 ms 892 KB Output is correct
63 Correct 3 ms 892 KB Output is correct
64 Correct 2 ms 892 KB Output is correct
65 Correct 4 ms 892 KB Output is correct
66 Correct 2 ms 892 KB Output is correct
67 Correct 2 ms 892 KB Output is correct
68 Correct 2 ms 892 KB Output is correct
69 Correct 2 ms 892 KB Output is correct
70 Correct 3 ms 892 KB Output is correct
71 Correct 226 ms 18188 KB Output is correct
72 Correct 174 ms 18188 KB Output is correct
73 Correct 235 ms 18188 KB Output is correct
74 Correct 121 ms 18188 KB Output is correct
75 Correct 139 ms 18188 KB Output is correct
76 Correct 425 ms 27348 KB Output is correct
77 Correct 329 ms 27348 KB Output is correct
78 Correct 303 ms 27348 KB Output is correct
79 Correct 285 ms 27348 KB Output is correct
80 Correct 2 ms 27348 KB Output is correct
81 Correct 2 ms 27348 KB Output is correct
82 Correct 4 ms 27348 KB Output is correct
83 Correct 35 ms 27348 KB Output is correct
84 Correct 44 ms 27348 KB Output is correct
85 Correct 10 ms 27348 KB Output is correct
86 Correct 2 ms 27348 KB Output is correct
87 Correct 51 ms 27348 KB Output is correct
88 Correct 3 ms 27348 KB Output is correct
89 Correct 3 ms 27348 KB Output is correct
90 Correct 3 ms 27348 KB Output is correct
91 Correct 15 ms 27348 KB Output is correct
92 Correct 59 ms 27348 KB Output is correct
93 Correct 1319 ms 90804 KB Output is correct
94 Correct 685 ms 90804 KB Output is correct
95 Correct 842 ms 90804 KB Output is correct
96 Correct 789 ms 90804 KB Output is correct
97 Correct 722 ms 90804 KB Output is correct
98 Correct 1539 ms 104672 KB Output is correct
99 Correct 1604 ms 110400 KB Output is correct
100 Correct 1520 ms 110400 KB Output is correct
101 Correct 1389 ms 110400 KB Output is correct
102 Correct 1322 ms 110400 KB Output is correct
103 Correct 994 ms 110400 KB Output is correct
104 Correct 3 ms 110400 KB Output is correct
105 Correct 3 ms 110400 KB Output is correct
106 Correct 6 ms 110400 KB Output is correct
107 Correct 109 ms 110400 KB Output is correct
108 Correct 315 ms 110400 KB Output is correct
109 Correct 24 ms 110400 KB Output is correct
110 Correct 3 ms 110400 KB Output is correct
111 Correct 137 ms 110400 KB Output is correct
112 Correct 3 ms 110400 KB Output is correct
113 Correct 2 ms 110400 KB Output is correct
114 Correct 7 ms 110400 KB Output is correct
115 Correct 3 ms 110400 KB Output is correct
116 Correct 11 ms 110400 KB Output is correct
117 Correct 285 ms 110400 KB Output is correct