답안 #70479

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70479 2018-08-23T04:04:54 Z 윤교준(#2187) Toys (CEOI18_toy) C++11
39 / 100
5000 ms 263168 KB
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int MAXX = 33005;

bitset<MAXX> isnp;

vector<vector<int>> G;

vector<pii> PV;
vector<int> POV;
vector<int> Ans;
int N;

void fact(vector<pii> &V, int N) {
	V.clear(); if(N < 2) return;
	if(!(N&1)) {
		for(V.eb(2, 0); !(N&1); V.back().second++, N >>= 1);
	}
	for(int i = 3; i*i <= N; i += 2) if(!isnp[i] && !(N%i)) {
		for(V.eb(i, 1), N /= i; !(N%i); V.back().second++, N /= i);
	}
	if(1 < N) V.eb(N, 1);
}

void naive(int i, int n, int g) {
	if(i == n) {
		int ret = 0;
		for(auto &V : G) {
			int t = 1;
			for(int v : V) t *= v;
			ret += t;
		}
		Ans.eb(ret - g);
		return;
	}

	int v = POV[i];
	for(int k = 0; k < g; k++) {
		G[k].eb(v);
		naive(i+1, n, g);
		G[k].pop_back();
	}
	G.eb(vector<int>(1, v));
	naive(i+1, n, g+1);
	G.pop_back();
}

int main() {
	isnp[0] = isnp[1] = true;
	for(int i = 4; i < MAXX; i += 2) isnp[i] = true;
	for(int i = 3; i*i < MAXX; i += 2) if(!isnp[i])
		for(int j = i*i; j < MAXX; j += i<<1) isnp[j] = true;
	
	cin >> N;
	if(1 == N) {
		puts("1\n0");
		return 0;
	}
	fact(PV, N);

	for(auto &v : PV) {
		int i, j; tie(i, j) = v;
		for(; j--;) POV.eb(i);
	}

	naive(0, sz(POV), 0);

	sorv(Ans); univ(Ans);
	printf("%d\n", sz(Ans));
	for(int v : Ans) printf("%d ", v);
	puts("");
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
7 Correct 2 ms 572 KB Output is correct
8 Correct 3 ms 572 KB Output is correct
9 Correct 2 ms 572 KB Output is correct
10 Correct 2 ms 572 KB Output is correct
11 Correct 2 ms 572 KB Output is correct
12 Correct 2 ms 572 KB Output is correct
13 Correct 2 ms 572 KB Output is correct
14 Correct 3 ms 572 KB Output is correct
15 Correct 3 ms 572 KB Output is correct
16 Correct 2 ms 572 KB Output is correct
17 Correct 2 ms 572 KB Output is correct
18 Correct 2 ms 572 KB Output is correct
19 Correct 3 ms 572 KB Output is correct
20 Correct 3 ms 572 KB Output is correct
21 Correct 2 ms 572 KB Output is correct
22 Correct 2 ms 572 KB Output is correct
23 Correct 2 ms 572 KB Output is correct
24 Correct 3 ms 572 KB Output is correct
25 Correct 2 ms 572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
7 Correct 2 ms 572 KB Output is correct
8 Correct 3 ms 572 KB Output is correct
9 Correct 2 ms 572 KB Output is correct
10 Correct 2 ms 572 KB Output is correct
11 Correct 2 ms 572 KB Output is correct
12 Correct 2 ms 572 KB Output is correct
13 Correct 2 ms 572 KB Output is correct
14 Correct 3 ms 572 KB Output is correct
15 Correct 3 ms 572 KB Output is correct
16 Correct 2 ms 572 KB Output is correct
17 Correct 2 ms 572 KB Output is correct
18 Correct 2 ms 572 KB Output is correct
19 Correct 3 ms 572 KB Output is correct
20 Correct 3 ms 572 KB Output is correct
21 Correct 2 ms 572 KB Output is correct
22 Correct 2 ms 572 KB Output is correct
23 Correct 2 ms 572 KB Output is correct
24 Correct 3 ms 572 KB Output is correct
25 Correct 2 ms 572 KB Output is correct
26 Correct 3 ms 588 KB Output is correct
27 Correct 3 ms 588 KB Output is correct
28 Correct 3 ms 620 KB Output is correct
29 Correct 2 ms 624 KB Output is correct
30 Correct 2 ms 624 KB Output is correct
31 Correct 15 ms 1276 KB Output is correct
32 Correct 5 ms 1276 KB Output is correct
33 Correct 5 ms 1276 KB Output is correct
34 Correct 2 ms 1276 KB Output is correct
35 Correct 3 ms 1276 KB Output is correct
36 Correct 3276 ms 132048 KB Output is correct
37 Correct 15 ms 132048 KB Output is correct
38 Correct 3 ms 132048 KB Output is correct
39 Correct 2 ms 132048 KB Output is correct
40 Correct 3 ms 132048 KB Output is correct
41 Correct 2 ms 132048 KB Output is correct
42 Correct 3 ms 132048 KB Output is correct
43 Correct 2 ms 132048 KB Output is correct
44 Correct 2 ms 132048 KB Output is correct
45 Correct 2 ms 132048 KB Output is correct
46 Correct 3 ms 132048 KB Output is correct
47 Correct 17 ms 132048 KB Output is correct
48 Correct 2 ms 132048 KB Output is correct
49 Correct 2 ms 132048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
7 Correct 2 ms 572 KB Output is correct
8 Correct 3 ms 572 KB Output is correct
9 Correct 2 ms 572 KB Output is correct
10 Correct 2 ms 572 KB Output is correct
11 Correct 2 ms 572 KB Output is correct
12 Correct 2 ms 572 KB Output is correct
13 Correct 2 ms 572 KB Output is correct
14 Correct 3 ms 572 KB Output is correct
15 Correct 3 ms 572 KB Output is correct
16 Correct 2 ms 572 KB Output is correct
17 Correct 2 ms 572 KB Output is correct
18 Correct 2 ms 572 KB Output is correct
19 Correct 3 ms 572 KB Output is correct
20 Correct 3 ms 572 KB Output is correct
21 Correct 2 ms 572 KB Output is correct
22 Correct 2 ms 572 KB Output is correct
23 Correct 2 ms 572 KB Output is correct
24 Correct 3 ms 572 KB Output is correct
25 Correct 2 ms 572 KB Output is correct
26 Correct 3 ms 588 KB Output is correct
27 Correct 3 ms 588 KB Output is correct
28 Correct 3 ms 620 KB Output is correct
29 Correct 2 ms 624 KB Output is correct
30 Correct 2 ms 624 KB Output is correct
31 Correct 15 ms 1276 KB Output is correct
32 Correct 5 ms 1276 KB Output is correct
33 Correct 5 ms 1276 KB Output is correct
34 Correct 2 ms 1276 KB Output is correct
35 Correct 3 ms 1276 KB Output is correct
36 Correct 3276 ms 132048 KB Output is correct
37 Correct 15 ms 132048 KB Output is correct
38 Correct 3 ms 132048 KB Output is correct
39 Correct 2 ms 132048 KB Output is correct
40 Correct 3 ms 132048 KB Output is correct
41 Correct 2 ms 132048 KB Output is correct
42 Correct 3 ms 132048 KB Output is correct
43 Correct 2 ms 132048 KB Output is correct
44 Correct 2 ms 132048 KB Output is correct
45 Correct 2 ms 132048 KB Output is correct
46 Correct 3 ms 132048 KB Output is correct
47 Correct 17 ms 132048 KB Output is correct
48 Correct 2 ms 132048 KB Output is correct
49 Correct 2 ms 132048 KB Output is correct
50 Correct 6 ms 132048 KB Output is correct
51 Correct 6 ms 132048 KB Output is correct
52 Correct 16 ms 132048 KB Output is correct
53 Correct 16 ms 132048 KB Output is correct
54 Correct 3 ms 132048 KB Output is correct
55 Correct 85 ms 132048 KB Output is correct
56 Correct 537 ms 132048 KB Output is correct
57 Correct 19 ms 132048 KB Output is correct
58 Correct 2 ms 132048 KB Output is correct
59 Correct 2 ms 132048 KB Output is correct
60 Execution timed out 5017 ms 263168 KB Time limit exceeded
61 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
7 Correct 2 ms 572 KB Output is correct
8 Correct 3 ms 572 KB Output is correct
9 Correct 2 ms 572 KB Output is correct
10 Correct 2 ms 572 KB Output is correct
11 Correct 2 ms 572 KB Output is correct
12 Correct 2 ms 572 KB Output is correct
13 Correct 2 ms 572 KB Output is correct
14 Correct 3 ms 572 KB Output is correct
15 Correct 3 ms 572 KB Output is correct
16 Correct 2 ms 572 KB Output is correct
17 Correct 2 ms 572 KB Output is correct
18 Correct 2 ms 572 KB Output is correct
19 Correct 3 ms 572 KB Output is correct
20 Correct 3 ms 572 KB Output is correct
21 Correct 2 ms 572 KB Output is correct
22 Correct 2 ms 572 KB Output is correct
23 Correct 2 ms 572 KB Output is correct
24 Correct 3 ms 572 KB Output is correct
25 Correct 2 ms 572 KB Output is correct
26 Correct 3 ms 588 KB Output is correct
27 Correct 3 ms 588 KB Output is correct
28 Correct 3 ms 620 KB Output is correct
29 Correct 2 ms 624 KB Output is correct
30 Correct 2 ms 624 KB Output is correct
31 Correct 15 ms 1276 KB Output is correct
32 Correct 5 ms 1276 KB Output is correct
33 Correct 5 ms 1276 KB Output is correct
34 Correct 2 ms 1276 KB Output is correct
35 Correct 3 ms 1276 KB Output is correct
36 Correct 3276 ms 132048 KB Output is correct
37 Correct 15 ms 132048 KB Output is correct
38 Correct 3 ms 132048 KB Output is correct
39 Correct 2 ms 132048 KB Output is correct
40 Correct 3 ms 132048 KB Output is correct
41 Correct 2 ms 132048 KB Output is correct
42 Correct 3 ms 132048 KB Output is correct
43 Correct 2 ms 132048 KB Output is correct
44 Correct 2 ms 132048 KB Output is correct
45 Correct 2 ms 132048 KB Output is correct
46 Correct 3 ms 132048 KB Output is correct
47 Correct 17 ms 132048 KB Output is correct
48 Correct 2 ms 132048 KB Output is correct
49 Correct 2 ms 132048 KB Output is correct
50 Correct 6 ms 132048 KB Output is correct
51 Correct 6 ms 132048 KB Output is correct
52 Correct 16 ms 132048 KB Output is correct
53 Correct 16 ms 132048 KB Output is correct
54 Correct 3 ms 132048 KB Output is correct
55 Correct 85 ms 132048 KB Output is correct
56 Correct 537 ms 132048 KB Output is correct
57 Correct 19 ms 132048 KB Output is correct
58 Correct 2 ms 132048 KB Output is correct
59 Correct 2 ms 132048 KB Output is correct
60 Execution timed out 5017 ms 263168 KB Time limit exceeded
61 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 488 KB Output is correct
6 Correct 2 ms 564 KB Output is correct
7 Correct 2 ms 572 KB Output is correct
8 Correct 3 ms 572 KB Output is correct
9 Correct 2 ms 572 KB Output is correct
10 Correct 2 ms 572 KB Output is correct
11 Correct 2 ms 572 KB Output is correct
12 Correct 2 ms 572 KB Output is correct
13 Correct 2 ms 572 KB Output is correct
14 Correct 3 ms 572 KB Output is correct
15 Correct 3 ms 572 KB Output is correct
16 Correct 2 ms 572 KB Output is correct
17 Correct 2 ms 572 KB Output is correct
18 Correct 2 ms 572 KB Output is correct
19 Correct 3 ms 572 KB Output is correct
20 Correct 3 ms 572 KB Output is correct
21 Correct 2 ms 572 KB Output is correct
22 Correct 2 ms 572 KB Output is correct
23 Correct 2 ms 572 KB Output is correct
24 Correct 3 ms 572 KB Output is correct
25 Correct 2 ms 572 KB Output is correct
26 Correct 3 ms 588 KB Output is correct
27 Correct 3 ms 588 KB Output is correct
28 Correct 3 ms 620 KB Output is correct
29 Correct 2 ms 624 KB Output is correct
30 Correct 2 ms 624 KB Output is correct
31 Correct 15 ms 1276 KB Output is correct
32 Correct 5 ms 1276 KB Output is correct
33 Correct 5 ms 1276 KB Output is correct
34 Correct 2 ms 1276 KB Output is correct
35 Correct 3 ms 1276 KB Output is correct
36 Correct 3276 ms 132048 KB Output is correct
37 Correct 15 ms 132048 KB Output is correct
38 Correct 3 ms 132048 KB Output is correct
39 Correct 2 ms 132048 KB Output is correct
40 Correct 3 ms 132048 KB Output is correct
41 Correct 2 ms 132048 KB Output is correct
42 Correct 3 ms 132048 KB Output is correct
43 Correct 2 ms 132048 KB Output is correct
44 Correct 2 ms 132048 KB Output is correct
45 Correct 2 ms 132048 KB Output is correct
46 Correct 3 ms 132048 KB Output is correct
47 Correct 17 ms 132048 KB Output is correct
48 Correct 2 ms 132048 KB Output is correct
49 Correct 2 ms 132048 KB Output is correct
50 Correct 6 ms 132048 KB Output is correct
51 Correct 6 ms 132048 KB Output is correct
52 Correct 16 ms 132048 KB Output is correct
53 Correct 16 ms 132048 KB Output is correct
54 Correct 3 ms 132048 KB Output is correct
55 Correct 85 ms 132048 KB Output is correct
56 Correct 537 ms 132048 KB Output is correct
57 Correct 19 ms 132048 KB Output is correct
58 Correct 2 ms 132048 KB Output is correct
59 Correct 2 ms 132048 KB Output is correct
60 Execution timed out 5017 ms 263168 KB Time limit exceeded
61 Halted 0 ms 0 KB -