답안 #70632

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70632 2018-08-23T07:55:00 Z ics0503 Toys (CEOI18_toy) C++17
100 / 100
1524 ms 121520 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 6 ms 3192 KB Output is correct
2 Correct 5 ms 3276 KB Output is correct
3 Correct 6 ms 3300 KB Output is correct
4 Correct 6 ms 3300 KB Output is correct
5 Correct 6 ms 3300 KB Output is correct
6 Correct 5 ms 3364 KB Output is correct
7 Correct 5 ms 3364 KB Output is correct
8 Correct 5 ms 3364 KB Output is correct
9 Correct 4 ms 3364 KB Output is correct
10 Correct 6 ms 3364 KB Output is correct
11 Correct 6 ms 3412 KB Output is correct
12 Correct 5 ms 3412 KB Output is correct
13 Correct 4 ms 3412 KB Output is correct
14 Correct 5 ms 3412 KB Output is correct
15 Correct 5 ms 3412 KB Output is correct
16 Correct 5 ms 3412 KB Output is correct
17 Correct 4 ms 3412 KB Output is correct
18 Correct 5 ms 3412 KB Output is correct
19 Correct 6 ms 3428 KB Output is correct
20 Correct 5 ms 3428 KB Output is correct
21 Correct 6 ms 3428 KB Output is correct
22 Correct 5 ms 3428 KB Output is correct
23 Correct 5 ms 3552 KB Output is correct
24 Correct 5 ms 3552 KB Output is correct
25 Correct 5 ms 3552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3192 KB Output is correct
2 Correct 5 ms 3276 KB Output is correct
3 Correct 6 ms 3300 KB Output is correct
4 Correct 6 ms 3300 KB Output is correct
5 Correct 6 ms 3300 KB Output is correct
6 Correct 5 ms 3364 KB Output is correct
7 Correct 5 ms 3364 KB Output is correct
8 Correct 5 ms 3364 KB Output is correct
9 Correct 4 ms 3364 KB Output is correct
10 Correct 6 ms 3364 KB Output is correct
11 Correct 6 ms 3412 KB Output is correct
12 Correct 5 ms 3412 KB Output is correct
13 Correct 4 ms 3412 KB Output is correct
14 Correct 5 ms 3412 KB Output is correct
15 Correct 5 ms 3412 KB Output is correct
16 Correct 5 ms 3412 KB Output is correct
17 Correct 4 ms 3412 KB Output is correct
18 Correct 5 ms 3412 KB Output is correct
19 Correct 6 ms 3428 KB Output is correct
20 Correct 5 ms 3428 KB Output is correct
21 Correct 6 ms 3428 KB Output is correct
22 Correct 5 ms 3428 KB Output is correct
23 Correct 5 ms 3552 KB Output is correct
24 Correct 5 ms 3552 KB Output is correct
25 Correct 5 ms 3552 KB Output is correct
26 Correct 5 ms 3552 KB Output is correct
27 Correct 7 ms 3552 KB Output is correct
28 Correct 6 ms 3552 KB Output is correct
29 Correct 5 ms 3552 KB Output is correct
30 Correct 5 ms 3552 KB Output is correct
31 Correct 5 ms 3552 KB Output is correct
32 Correct 5 ms 3552 KB Output is correct
33 Correct 5 ms 3552 KB Output is correct
34 Correct 5 ms 3552 KB Output is correct
35 Correct 4 ms 3552 KB Output is correct
36 Correct 4 ms 3552 KB Output is correct
37 Correct 6 ms 3552 KB Output is correct
38 Correct 6 ms 3552 KB Output is correct
39 Correct 6 ms 3552 KB Output is correct
40 Correct 6 ms 3572 KB Output is correct
41 Correct 5 ms 3572 KB Output is correct
42 Correct 5 ms 3572 KB Output is correct
43 Correct 5 ms 3572 KB Output is correct
44 Correct 6 ms 3572 KB Output is correct
45 Correct 5 ms 3572 KB Output is correct
46 Correct 6 ms 3572 KB Output is correct
47 Correct 5 ms 3572 KB Output is correct
48 Correct 5 ms 3572 KB Output is correct
49 Correct 5 ms 3572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3192 KB Output is correct
2 Correct 5 ms 3276 KB Output is correct
3 Correct 6 ms 3300 KB Output is correct
4 Correct 6 ms 3300 KB Output is correct
5 Correct 6 ms 3300 KB Output is correct
6 Correct 5 ms 3364 KB Output is correct
7 Correct 5 ms 3364 KB Output is correct
8 Correct 5 ms 3364 KB Output is correct
9 Correct 4 ms 3364 KB Output is correct
10 Correct 6 ms 3364 KB Output is correct
11 Correct 6 ms 3412 KB Output is correct
12 Correct 5 ms 3412 KB Output is correct
13 Correct 4 ms 3412 KB Output is correct
14 Correct 5 ms 3412 KB Output is correct
15 Correct 5 ms 3412 KB Output is correct
16 Correct 5 ms 3412 KB Output is correct
17 Correct 4 ms 3412 KB Output is correct
18 Correct 5 ms 3412 KB Output is correct
19 Correct 6 ms 3428 KB Output is correct
20 Correct 5 ms 3428 KB Output is correct
21 Correct 6 ms 3428 KB Output is correct
22 Correct 5 ms 3428 KB Output is correct
23 Correct 5 ms 3552 KB Output is correct
24 Correct 5 ms 3552 KB Output is correct
25 Correct 5 ms 3552 KB Output is correct
26 Correct 5 ms 3552 KB Output is correct
27 Correct 7 ms 3552 KB Output is correct
28 Correct 6 ms 3552 KB Output is correct
29 Correct 5 ms 3552 KB Output is correct
30 Correct 5 ms 3552 KB Output is correct
31 Correct 5 ms 3552 KB Output is correct
32 Correct 5 ms 3552 KB Output is correct
33 Correct 5 ms 3552 KB Output is correct
34 Correct 5 ms 3552 KB Output is correct
35 Correct 4 ms 3552 KB Output is correct
36 Correct 4 ms 3552 KB Output is correct
37 Correct 6 ms 3552 KB Output is correct
38 Correct 6 ms 3552 KB Output is correct
39 Correct 6 ms 3552 KB Output is correct
40 Correct 6 ms 3572 KB Output is correct
41 Correct 5 ms 3572 KB Output is correct
42 Correct 5 ms 3572 KB Output is correct
43 Correct 5 ms 3572 KB Output is correct
44 Correct 6 ms 3572 KB Output is correct
45 Correct 5 ms 3572 KB Output is correct
46 Correct 6 ms 3572 KB Output is correct
47 Correct 5 ms 3572 KB Output is correct
48 Correct 5 ms 3572 KB Output is correct
49 Correct 5 ms 3572 KB Output is correct
50 Correct 7 ms 3580 KB Output is correct
51 Correct 7 ms 3580 KB Output is correct
52 Correct 6 ms 3580 KB Output is correct
53 Correct 6 ms 3580 KB Output is correct
54 Correct 6 ms 3580 KB Output is correct
55 Correct 9 ms 3708 KB Output is correct
56 Correct 9 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 6 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 6 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 6 ms 3708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3192 KB Output is correct
2 Correct 5 ms 3276 KB Output is correct
3 Correct 6 ms 3300 KB Output is correct
4 Correct 6 ms 3300 KB Output is correct
5 Correct 6 ms 3300 KB Output is correct
6 Correct 5 ms 3364 KB Output is correct
7 Correct 5 ms 3364 KB Output is correct
8 Correct 5 ms 3364 KB Output is correct
9 Correct 4 ms 3364 KB Output is correct
10 Correct 6 ms 3364 KB Output is correct
11 Correct 6 ms 3412 KB Output is correct
12 Correct 5 ms 3412 KB Output is correct
13 Correct 4 ms 3412 KB Output is correct
14 Correct 5 ms 3412 KB Output is correct
15 Correct 5 ms 3412 KB Output is correct
16 Correct 5 ms 3412 KB Output is correct
17 Correct 4 ms 3412 KB Output is correct
18 Correct 5 ms 3412 KB Output is correct
19 Correct 6 ms 3428 KB Output is correct
20 Correct 5 ms 3428 KB Output is correct
21 Correct 6 ms 3428 KB Output is correct
22 Correct 5 ms 3428 KB Output is correct
23 Correct 5 ms 3552 KB Output is correct
24 Correct 5 ms 3552 KB Output is correct
25 Correct 5 ms 3552 KB Output is correct
26 Correct 5 ms 3552 KB Output is correct
27 Correct 7 ms 3552 KB Output is correct
28 Correct 6 ms 3552 KB Output is correct
29 Correct 5 ms 3552 KB Output is correct
30 Correct 5 ms 3552 KB Output is correct
31 Correct 5 ms 3552 KB Output is correct
32 Correct 5 ms 3552 KB Output is correct
33 Correct 5 ms 3552 KB Output is correct
34 Correct 5 ms 3552 KB Output is correct
35 Correct 4 ms 3552 KB Output is correct
36 Correct 4 ms 3552 KB Output is correct
37 Correct 6 ms 3552 KB Output is correct
38 Correct 6 ms 3552 KB Output is correct
39 Correct 6 ms 3552 KB Output is correct
40 Correct 6 ms 3572 KB Output is correct
41 Correct 5 ms 3572 KB Output is correct
42 Correct 5 ms 3572 KB Output is correct
43 Correct 5 ms 3572 KB Output is correct
44 Correct 6 ms 3572 KB Output is correct
45 Correct 5 ms 3572 KB Output is correct
46 Correct 6 ms 3572 KB Output is correct
47 Correct 5 ms 3572 KB Output is correct
48 Correct 5 ms 3572 KB Output is correct
49 Correct 5 ms 3572 KB Output is correct
50 Correct 7 ms 3580 KB Output is correct
51 Correct 7 ms 3580 KB Output is correct
52 Correct 6 ms 3580 KB Output is correct
53 Correct 6 ms 3580 KB Output is correct
54 Correct 6 ms 3580 KB Output is correct
55 Correct 9 ms 3708 KB Output is correct
56 Correct 9 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 6 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 6 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 6 ms 3708 KB Output is correct
71 Correct 225 ms 21744 KB Output is correct
72 Correct 165 ms 21744 KB Output is correct
73 Correct 238 ms 21744 KB Output is correct
74 Correct 132 ms 21744 KB Output is correct
75 Correct 143 ms 21744 KB Output is correct
76 Correct 388 ms 31516 KB Output is correct
77 Correct 346 ms 31516 KB Output is correct
78 Correct 324 ms 31516 KB Output is correct
79 Correct 317 ms 31516 KB Output is correct
80 Correct 5 ms 31516 KB Output is correct
81 Correct 5 ms 31516 KB Output is correct
82 Correct 7 ms 31516 KB Output is correct
83 Correct 34 ms 31516 KB Output is correct
84 Correct 42 ms 31516 KB Output is correct
85 Correct 13 ms 31516 KB Output is correct
86 Correct 7 ms 31516 KB Output is correct
87 Correct 45 ms 31516 KB Output is correct
88 Correct 5 ms 31516 KB Output is correct
89 Correct 6 ms 31516 KB Output is correct
90 Correct 5 ms 31516 KB Output is correct
91 Correct 16 ms 31516 KB Output is correct
92 Correct 56 ms 31516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 3192 KB Output is correct
2 Correct 5 ms 3276 KB Output is correct
3 Correct 6 ms 3300 KB Output is correct
4 Correct 6 ms 3300 KB Output is correct
5 Correct 6 ms 3300 KB Output is correct
6 Correct 5 ms 3364 KB Output is correct
7 Correct 5 ms 3364 KB Output is correct
8 Correct 5 ms 3364 KB Output is correct
9 Correct 4 ms 3364 KB Output is correct
10 Correct 6 ms 3364 KB Output is correct
11 Correct 6 ms 3412 KB Output is correct
12 Correct 5 ms 3412 KB Output is correct
13 Correct 4 ms 3412 KB Output is correct
14 Correct 5 ms 3412 KB Output is correct
15 Correct 5 ms 3412 KB Output is correct
16 Correct 5 ms 3412 KB Output is correct
17 Correct 4 ms 3412 KB Output is correct
18 Correct 5 ms 3412 KB Output is correct
19 Correct 6 ms 3428 KB Output is correct
20 Correct 5 ms 3428 KB Output is correct
21 Correct 6 ms 3428 KB Output is correct
22 Correct 5 ms 3428 KB Output is correct
23 Correct 5 ms 3552 KB Output is correct
24 Correct 5 ms 3552 KB Output is correct
25 Correct 5 ms 3552 KB Output is correct
26 Correct 5 ms 3552 KB Output is correct
27 Correct 7 ms 3552 KB Output is correct
28 Correct 6 ms 3552 KB Output is correct
29 Correct 5 ms 3552 KB Output is correct
30 Correct 5 ms 3552 KB Output is correct
31 Correct 5 ms 3552 KB Output is correct
32 Correct 5 ms 3552 KB Output is correct
33 Correct 5 ms 3552 KB Output is correct
34 Correct 5 ms 3552 KB Output is correct
35 Correct 4 ms 3552 KB Output is correct
36 Correct 4 ms 3552 KB Output is correct
37 Correct 6 ms 3552 KB Output is correct
38 Correct 6 ms 3552 KB Output is correct
39 Correct 6 ms 3552 KB Output is correct
40 Correct 6 ms 3572 KB Output is correct
41 Correct 5 ms 3572 KB Output is correct
42 Correct 5 ms 3572 KB Output is correct
43 Correct 5 ms 3572 KB Output is correct
44 Correct 6 ms 3572 KB Output is correct
45 Correct 5 ms 3572 KB Output is correct
46 Correct 6 ms 3572 KB Output is correct
47 Correct 5 ms 3572 KB Output is correct
48 Correct 5 ms 3572 KB Output is correct
49 Correct 5 ms 3572 KB Output is correct
50 Correct 7 ms 3580 KB Output is correct
51 Correct 7 ms 3580 KB Output is correct
52 Correct 6 ms 3580 KB Output is correct
53 Correct 6 ms 3580 KB Output is correct
54 Correct 6 ms 3580 KB Output is correct
55 Correct 9 ms 3708 KB Output is correct
56 Correct 9 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 6 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 6 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 6 ms 3708 KB Output is correct
71 Correct 225 ms 21744 KB Output is correct
72 Correct 165 ms 21744 KB Output is correct
73 Correct 238 ms 21744 KB Output is correct
74 Correct 132 ms 21744 KB Output is correct
75 Correct 143 ms 21744 KB Output is correct
76 Correct 388 ms 31516 KB Output is correct
77 Correct 346 ms 31516 KB Output is correct
78 Correct 324 ms 31516 KB Output is correct
79 Correct 317 ms 31516 KB Output is correct
80 Correct 5 ms 31516 KB Output is correct
81 Correct 5 ms 31516 KB Output is correct
82 Correct 7 ms 31516 KB Output is correct
83 Correct 34 ms 31516 KB Output is correct
84 Correct 42 ms 31516 KB Output is correct
85 Correct 13 ms 31516 KB Output is correct
86 Correct 7 ms 31516 KB Output is correct
87 Correct 45 ms 31516 KB Output is correct
88 Correct 5 ms 31516 KB Output is correct
89 Correct 6 ms 31516 KB Output is correct
90 Correct 5 ms 31516 KB Output is correct
91 Correct 16 ms 31516 KB Output is correct
92 Correct 56 ms 31516 KB Output is correct
93 Correct 1304 ms 100692 KB Output is correct
94 Correct 722 ms 100692 KB Output is correct
95 Correct 872 ms 100692 KB Output is correct
96 Correct 737 ms 100692 KB Output is correct
97 Correct 701 ms 100692 KB Output is correct
98 Correct 1481 ms 115180 KB Output is correct
99 Correct 1524 ms 121520 KB Output is correct
100 Correct 1427 ms 121520 KB Output is correct
101 Correct 1415 ms 121520 KB Output is correct
102 Correct 1244 ms 121520 KB Output is correct
103 Correct 931 ms 121520 KB Output is correct
104 Correct 6 ms 121520 KB Output is correct
105 Correct 5 ms 121520 KB Output is correct
106 Correct 8 ms 121520 KB Output is correct
107 Correct 100 ms 121520 KB Output is correct
108 Correct 260 ms 121520 KB Output is correct
109 Correct 26 ms 121520 KB Output is correct
110 Correct 5 ms 121520 KB Output is correct
111 Correct 131 ms 121520 KB Output is correct
112 Correct 5 ms 121520 KB Output is correct
113 Correct 5 ms 121520 KB Output is correct
114 Correct 11 ms 121520 KB Output is correct
115 Correct 5 ms 121520 KB Output is correct
116 Correct 13 ms 121520 KB Output is correct
117 Correct 260 ms 121520 KB Output is correct