답안 #70612

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70612 2018-08-23T07:31:32 Z cs(#2192) Toys (CEOI18_toy) C++11
100 / 100
1571 ms 121540 KB
#include<stdio.h>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int mn;
map<int, int>M;
vector<int>L[121212];
void get_ans(int n) {
	if (M.find(n) != M.end())return;
	int now = M[n] = ++mn; L[mn].push_back(n - 1);
	int i, j, w;
	for (i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			get_ans(i), get_ans(n / i);
			w = M[i];
			for (j = 0; j < L[w].size(); j++)
				L[now].push_back(L[w][j] + ((n / i) - 1));
			w = M[n/i];
			for (j = 0; j < L[w].size(); j++)
				L[now].push_back(L[w][j] + (i - 1));
		}
	}
	sort(L[now].begin(),L[now].end());
	L[now].erase(unique(L[now].begin(), L[now].end()), L[now].end());
}

int main() {
	long long n, i, j; scanf("%d", &n);
	get_ans(n);
	int w = M[n];
	printf("%d\n", L[w].size());
	for (i = 0; i < L[w].size(); i++) {
		printf("%d ", L[w][i]);
	}
	return 0;
}

Compilation message

toy.cpp: In function 'void get_ans(int)':
toy.cpp:17:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (j = 0; j < L[w].size(); j++)
                ~~^~~~~~~~~~~~~
toy.cpp:20:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (j = 0; j < L[w].size(); j++)
                ~~^~~~~~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:29:35: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
  long long n, i, j; scanf("%d", &n);
                                 ~~^
toy.cpp:32:28: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d\n", L[w].size());
                 ~~~~~~~~~~~^
toy.cpp:33:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < L[w].size(); i++) {
              ~~^~~~~~~~~~~~~
toy.cpp:29:18: warning: unused variable 'j' [-Wunused-variable]
  long long n, i, j; scanf("%d", &n);
                  ^
toy.cpp:29:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  long long n, i, j; scanf("%d", &n);
                     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3192 KB Output is correct
2 Correct 6 ms 3276 KB Output is correct
3 Correct 7 ms 3292 KB Output is correct
4 Correct 5 ms 3292 KB Output is correct
5 Correct 4 ms 3292 KB Output is correct
6 Correct 5 ms 3336 KB Output is correct
7 Correct 5 ms 3464 KB Output is correct
8 Correct 5 ms 3464 KB Output is correct
9 Correct 4 ms 3464 KB Output is correct
10 Correct 4 ms 3464 KB Output is correct
11 Correct 4 ms 3464 KB Output is correct
12 Correct 5 ms 3532 KB Output is correct
13 Correct 4 ms 3532 KB Output is correct
14 Correct 5 ms 3532 KB Output is correct
15 Correct 4 ms 3532 KB Output is correct
16 Correct 5 ms 3532 KB Output is correct
17 Correct 4 ms 3532 KB Output is correct
18 Correct 5 ms 3532 KB Output is correct
19 Correct 5 ms 3532 KB Output is correct
20 Correct 5 ms 3548 KB Output is correct
21 Correct 5 ms 3548 KB Output is correct
22 Correct 7 ms 3548 KB Output is correct
23 Correct 5 ms 3548 KB Output is correct
24 Correct 5 ms 3548 KB Output is correct
25 Correct 5 ms 3548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3192 KB Output is correct
2 Correct 6 ms 3276 KB Output is correct
3 Correct 7 ms 3292 KB Output is correct
4 Correct 5 ms 3292 KB Output is correct
5 Correct 4 ms 3292 KB Output is correct
6 Correct 5 ms 3336 KB Output is correct
7 Correct 5 ms 3464 KB Output is correct
8 Correct 5 ms 3464 KB Output is correct
9 Correct 4 ms 3464 KB Output is correct
10 Correct 4 ms 3464 KB Output is correct
11 Correct 4 ms 3464 KB Output is correct
12 Correct 5 ms 3532 KB Output is correct
13 Correct 4 ms 3532 KB Output is correct
14 Correct 5 ms 3532 KB Output is correct
15 Correct 4 ms 3532 KB Output is correct
16 Correct 5 ms 3532 KB Output is correct
17 Correct 4 ms 3532 KB Output is correct
18 Correct 5 ms 3532 KB Output is correct
19 Correct 5 ms 3532 KB Output is correct
20 Correct 5 ms 3548 KB Output is correct
21 Correct 5 ms 3548 KB Output is correct
22 Correct 7 ms 3548 KB Output is correct
23 Correct 5 ms 3548 KB Output is correct
24 Correct 5 ms 3548 KB Output is correct
25 Correct 5 ms 3548 KB Output is correct
26 Correct 6 ms 3548 KB Output is correct
27 Correct 6 ms 3548 KB Output is correct
28 Correct 5 ms 3548 KB Output is correct
29 Correct 5 ms 3548 KB Output is correct
30 Correct 5 ms 3548 KB Output is correct
31 Correct 5 ms 3556 KB Output is correct
32 Correct 4 ms 3556 KB Output is correct
33 Correct 6 ms 3556 KB Output is correct
34 Correct 5 ms 3556 KB Output is correct
35 Correct 5 ms 3556 KB Output is correct
36 Correct 5 ms 3556 KB Output is correct
37 Correct 6 ms 3564 KB Output is correct
38 Correct 5 ms 3564 KB Output is correct
39 Correct 5 ms 3564 KB Output is correct
40 Correct 5 ms 3564 KB Output is correct
41 Correct 4 ms 3564 KB Output is correct
42 Correct 5 ms 3564 KB Output is correct
43 Correct 5 ms 3564 KB Output is correct
44 Correct 6 ms 3564 KB Output is correct
45 Correct 5 ms 3564 KB Output is correct
46 Correct 6 ms 3564 KB Output is correct
47 Correct 6 ms 3564 KB Output is correct
48 Correct 5 ms 3564 KB Output is correct
49 Correct 6 ms 3564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3192 KB Output is correct
2 Correct 6 ms 3276 KB Output is correct
3 Correct 7 ms 3292 KB Output is correct
4 Correct 5 ms 3292 KB Output is correct
5 Correct 4 ms 3292 KB Output is correct
6 Correct 5 ms 3336 KB Output is correct
7 Correct 5 ms 3464 KB Output is correct
8 Correct 5 ms 3464 KB Output is correct
9 Correct 4 ms 3464 KB Output is correct
10 Correct 4 ms 3464 KB Output is correct
11 Correct 4 ms 3464 KB Output is correct
12 Correct 5 ms 3532 KB Output is correct
13 Correct 4 ms 3532 KB Output is correct
14 Correct 5 ms 3532 KB Output is correct
15 Correct 4 ms 3532 KB Output is correct
16 Correct 5 ms 3532 KB Output is correct
17 Correct 4 ms 3532 KB Output is correct
18 Correct 5 ms 3532 KB Output is correct
19 Correct 5 ms 3532 KB Output is correct
20 Correct 5 ms 3548 KB Output is correct
21 Correct 5 ms 3548 KB Output is correct
22 Correct 7 ms 3548 KB Output is correct
23 Correct 5 ms 3548 KB Output is correct
24 Correct 5 ms 3548 KB Output is correct
25 Correct 5 ms 3548 KB Output is correct
26 Correct 6 ms 3548 KB Output is correct
27 Correct 6 ms 3548 KB Output is correct
28 Correct 5 ms 3548 KB Output is correct
29 Correct 5 ms 3548 KB Output is correct
30 Correct 5 ms 3548 KB Output is correct
31 Correct 5 ms 3556 KB Output is correct
32 Correct 4 ms 3556 KB Output is correct
33 Correct 6 ms 3556 KB Output is correct
34 Correct 5 ms 3556 KB Output is correct
35 Correct 5 ms 3556 KB Output is correct
36 Correct 5 ms 3556 KB Output is correct
37 Correct 6 ms 3564 KB Output is correct
38 Correct 5 ms 3564 KB Output is correct
39 Correct 5 ms 3564 KB Output is correct
40 Correct 5 ms 3564 KB Output is correct
41 Correct 4 ms 3564 KB Output is correct
42 Correct 5 ms 3564 KB Output is correct
43 Correct 5 ms 3564 KB Output is correct
44 Correct 6 ms 3564 KB Output is correct
45 Correct 5 ms 3564 KB Output is correct
46 Correct 6 ms 3564 KB Output is correct
47 Correct 6 ms 3564 KB Output is correct
48 Correct 5 ms 3564 KB Output is correct
49 Correct 6 ms 3564 KB Output is correct
50 Correct 7 ms 3580 KB Output is correct
51 Correct 7 ms 3584 KB Output is correct
52 Correct 8 ms 3584 KB Output is correct
53 Correct 7 ms 3584 KB Output is correct
54 Correct 7 ms 3584 KB Output is correct
55 Correct 8 ms 3708 KB Output is correct
56 Correct 7 ms 3708 KB Output is correct
57 Correct 7 ms 3708 KB Output is correct
58 Correct 5 ms 3708 KB Output is correct
59 Correct 5 ms 3708 KB Output is correct
60 Correct 5 ms 3708 KB Output is correct
61 Correct 7 ms 3708 KB Output is correct
62 Correct 5 ms 3708 KB Output is correct
63 Correct 5 ms 3708 KB Output is correct
64 Correct 5 ms 3708 KB Output is correct
65 Correct 5 ms 3708 KB Output is correct
66 Correct 4 ms 3708 KB Output is correct
67 Correct 5 ms 3708 KB Output is correct
68 Correct 5 ms 3708 KB Output is correct
69 Correct 5 ms 3708 KB Output is correct
70 Correct 5 ms 3708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3192 KB Output is correct
2 Correct 6 ms 3276 KB Output is correct
3 Correct 7 ms 3292 KB Output is correct
4 Correct 5 ms 3292 KB Output is correct
5 Correct 4 ms 3292 KB Output is correct
6 Correct 5 ms 3336 KB Output is correct
7 Correct 5 ms 3464 KB Output is correct
8 Correct 5 ms 3464 KB Output is correct
9 Correct 4 ms 3464 KB Output is correct
10 Correct 4 ms 3464 KB Output is correct
11 Correct 4 ms 3464 KB Output is correct
12 Correct 5 ms 3532 KB Output is correct
13 Correct 4 ms 3532 KB Output is correct
14 Correct 5 ms 3532 KB Output is correct
15 Correct 4 ms 3532 KB Output is correct
16 Correct 5 ms 3532 KB Output is correct
17 Correct 4 ms 3532 KB Output is correct
18 Correct 5 ms 3532 KB Output is correct
19 Correct 5 ms 3532 KB Output is correct
20 Correct 5 ms 3548 KB Output is correct
21 Correct 5 ms 3548 KB Output is correct
22 Correct 7 ms 3548 KB Output is correct
23 Correct 5 ms 3548 KB Output is correct
24 Correct 5 ms 3548 KB Output is correct
25 Correct 5 ms 3548 KB Output is correct
26 Correct 6 ms 3548 KB Output is correct
27 Correct 6 ms 3548 KB Output is correct
28 Correct 5 ms 3548 KB Output is correct
29 Correct 5 ms 3548 KB Output is correct
30 Correct 5 ms 3548 KB Output is correct
31 Correct 5 ms 3556 KB Output is correct
32 Correct 4 ms 3556 KB Output is correct
33 Correct 6 ms 3556 KB Output is correct
34 Correct 5 ms 3556 KB Output is correct
35 Correct 5 ms 3556 KB Output is correct
36 Correct 5 ms 3556 KB Output is correct
37 Correct 6 ms 3564 KB Output is correct
38 Correct 5 ms 3564 KB Output is correct
39 Correct 5 ms 3564 KB Output is correct
40 Correct 5 ms 3564 KB Output is correct
41 Correct 4 ms 3564 KB Output is correct
42 Correct 5 ms 3564 KB Output is correct
43 Correct 5 ms 3564 KB Output is correct
44 Correct 6 ms 3564 KB Output is correct
45 Correct 5 ms 3564 KB Output is correct
46 Correct 6 ms 3564 KB Output is correct
47 Correct 6 ms 3564 KB Output is correct
48 Correct 5 ms 3564 KB Output is correct
49 Correct 6 ms 3564 KB Output is correct
50 Correct 7 ms 3580 KB Output is correct
51 Correct 7 ms 3584 KB Output is correct
52 Correct 8 ms 3584 KB Output is correct
53 Correct 7 ms 3584 KB Output is correct
54 Correct 7 ms 3584 KB Output is correct
55 Correct 8 ms 3708 KB Output is correct
56 Correct 7 ms 3708 KB Output is correct
57 Correct 7 ms 3708 KB Output is correct
58 Correct 5 ms 3708 KB Output is correct
59 Correct 5 ms 3708 KB Output is correct
60 Correct 5 ms 3708 KB Output is correct
61 Correct 7 ms 3708 KB Output is correct
62 Correct 5 ms 3708 KB Output is correct
63 Correct 5 ms 3708 KB Output is correct
64 Correct 5 ms 3708 KB Output is correct
65 Correct 5 ms 3708 KB Output is correct
66 Correct 4 ms 3708 KB Output is correct
67 Correct 5 ms 3708 KB Output is correct
68 Correct 5 ms 3708 KB Output is correct
69 Correct 5 ms 3708 KB Output is correct
70 Correct 5 ms 3708 KB Output is correct
71 Correct 241 ms 21772 KB Output is correct
72 Correct 154 ms 21772 KB Output is correct
73 Correct 217 ms 21772 KB Output is correct
74 Correct 140 ms 21772 KB Output is correct
75 Correct 144 ms 21772 KB Output is correct
76 Correct 354 ms 31500 KB Output is correct
77 Correct 332 ms 31500 KB Output is correct
78 Correct 279 ms 31500 KB Output is correct
79 Correct 293 ms 31500 KB Output is correct
80 Correct 4 ms 31500 KB Output is correct
81 Correct 5 ms 31500 KB Output is correct
82 Correct 7 ms 31500 KB Output is correct
83 Correct 38 ms 31500 KB Output is correct
84 Correct 41 ms 31500 KB Output is correct
85 Correct 14 ms 31500 KB Output is correct
86 Correct 4 ms 31500 KB Output is correct
87 Correct 46 ms 31500 KB Output is correct
88 Correct 5 ms 31500 KB Output is correct
89 Correct 5 ms 31500 KB Output is correct
90 Correct 6 ms 31500 KB Output is correct
91 Correct 17 ms 31500 KB Output is correct
92 Correct 59 ms 31500 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3192 KB Output is correct
2 Correct 6 ms 3276 KB Output is correct
3 Correct 7 ms 3292 KB Output is correct
4 Correct 5 ms 3292 KB Output is correct
5 Correct 4 ms 3292 KB Output is correct
6 Correct 5 ms 3336 KB Output is correct
7 Correct 5 ms 3464 KB Output is correct
8 Correct 5 ms 3464 KB Output is correct
9 Correct 4 ms 3464 KB Output is correct
10 Correct 4 ms 3464 KB Output is correct
11 Correct 4 ms 3464 KB Output is correct
12 Correct 5 ms 3532 KB Output is correct
13 Correct 4 ms 3532 KB Output is correct
14 Correct 5 ms 3532 KB Output is correct
15 Correct 4 ms 3532 KB Output is correct
16 Correct 5 ms 3532 KB Output is correct
17 Correct 4 ms 3532 KB Output is correct
18 Correct 5 ms 3532 KB Output is correct
19 Correct 5 ms 3532 KB Output is correct
20 Correct 5 ms 3548 KB Output is correct
21 Correct 5 ms 3548 KB Output is correct
22 Correct 7 ms 3548 KB Output is correct
23 Correct 5 ms 3548 KB Output is correct
24 Correct 5 ms 3548 KB Output is correct
25 Correct 5 ms 3548 KB Output is correct
26 Correct 6 ms 3548 KB Output is correct
27 Correct 6 ms 3548 KB Output is correct
28 Correct 5 ms 3548 KB Output is correct
29 Correct 5 ms 3548 KB Output is correct
30 Correct 5 ms 3548 KB Output is correct
31 Correct 5 ms 3556 KB Output is correct
32 Correct 4 ms 3556 KB Output is correct
33 Correct 6 ms 3556 KB Output is correct
34 Correct 5 ms 3556 KB Output is correct
35 Correct 5 ms 3556 KB Output is correct
36 Correct 5 ms 3556 KB Output is correct
37 Correct 6 ms 3564 KB Output is correct
38 Correct 5 ms 3564 KB Output is correct
39 Correct 5 ms 3564 KB Output is correct
40 Correct 5 ms 3564 KB Output is correct
41 Correct 4 ms 3564 KB Output is correct
42 Correct 5 ms 3564 KB Output is correct
43 Correct 5 ms 3564 KB Output is correct
44 Correct 6 ms 3564 KB Output is correct
45 Correct 5 ms 3564 KB Output is correct
46 Correct 6 ms 3564 KB Output is correct
47 Correct 6 ms 3564 KB Output is correct
48 Correct 5 ms 3564 KB Output is correct
49 Correct 6 ms 3564 KB Output is correct
50 Correct 7 ms 3580 KB Output is correct
51 Correct 7 ms 3584 KB Output is correct
52 Correct 8 ms 3584 KB Output is correct
53 Correct 7 ms 3584 KB Output is correct
54 Correct 7 ms 3584 KB Output is correct
55 Correct 8 ms 3708 KB Output is correct
56 Correct 7 ms 3708 KB Output is correct
57 Correct 7 ms 3708 KB Output is correct
58 Correct 5 ms 3708 KB Output is correct
59 Correct 5 ms 3708 KB Output is correct
60 Correct 5 ms 3708 KB Output is correct
61 Correct 7 ms 3708 KB Output is correct
62 Correct 5 ms 3708 KB Output is correct
63 Correct 5 ms 3708 KB Output is correct
64 Correct 5 ms 3708 KB Output is correct
65 Correct 5 ms 3708 KB Output is correct
66 Correct 4 ms 3708 KB Output is correct
67 Correct 5 ms 3708 KB Output is correct
68 Correct 5 ms 3708 KB Output is correct
69 Correct 5 ms 3708 KB Output is correct
70 Correct 5 ms 3708 KB Output is correct
71 Correct 241 ms 21772 KB Output is correct
72 Correct 154 ms 21772 KB Output is correct
73 Correct 217 ms 21772 KB Output is correct
74 Correct 140 ms 21772 KB Output is correct
75 Correct 144 ms 21772 KB Output is correct
76 Correct 354 ms 31500 KB Output is correct
77 Correct 332 ms 31500 KB Output is correct
78 Correct 279 ms 31500 KB Output is correct
79 Correct 293 ms 31500 KB Output is correct
80 Correct 4 ms 31500 KB Output is correct
81 Correct 5 ms 31500 KB Output is correct
82 Correct 7 ms 31500 KB Output is correct
83 Correct 38 ms 31500 KB Output is correct
84 Correct 41 ms 31500 KB Output is correct
85 Correct 14 ms 31500 KB Output is correct
86 Correct 4 ms 31500 KB Output is correct
87 Correct 46 ms 31500 KB Output is correct
88 Correct 5 ms 31500 KB Output is correct
89 Correct 5 ms 31500 KB Output is correct
90 Correct 6 ms 31500 KB Output is correct
91 Correct 17 ms 31500 KB Output is correct
92 Correct 59 ms 31500 KB Output is correct
93 Correct 1291 ms 100660 KB Output is correct
94 Correct 676 ms 100660 KB Output is correct
95 Correct 823 ms 100660 KB Output is correct
96 Correct 744 ms 100660 KB Output is correct
97 Correct 712 ms 100660 KB Output is correct
98 Correct 1495 ms 115280 KB Output is correct
99 Correct 1571 ms 121540 KB Output is correct
100 Correct 1431 ms 121540 KB Output is correct
101 Correct 1377 ms 121540 KB Output is correct
102 Correct 1179 ms 121540 KB Output is correct
103 Correct 929 ms 121540 KB Output is correct
104 Correct 5 ms 121540 KB Output is correct
105 Correct 4 ms 121540 KB Output is correct
106 Correct 9 ms 121540 KB Output is correct
107 Correct 101 ms 121540 KB Output is correct
108 Correct 300 ms 121540 KB Output is correct
109 Correct 30 ms 121540 KB Output is correct
110 Correct 6 ms 121540 KB Output is correct
111 Correct 133 ms 121540 KB Output is correct
112 Correct 6 ms 121540 KB Output is correct
113 Correct 5 ms 121540 KB Output is correct
114 Correct 9 ms 121540 KB Output is correct
115 Correct 5 ms 121540 KB Output is correct
116 Correct 15 ms 121540 KB Output is correct
117 Correct 253 ms 121540 KB Output is correct