# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
267115 | 2020-08-15T20:49:11 Z | peuch | Toys (CEOI18_toy) | C++17 | 5000 ms | 5300 KB |
#include<bits/stdc++.h> using namespace std; #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") const int MAXN = 2e4; int n; int cnt; int v[MAXN], qnt[MAXN]; vector<int> ans; map<int, vector<int> > dp, divisor; void getDiv(int num); void calcDP(int num); int main(){ scanf("%d", &n); calcDP(n); sort(dp[n].begin(), dp[n].end()); printf("%lu\n", dp[n].size()); for(int i = 0; i < dp[n].size(); i++) printf("%d ", dp[n][i]); printf("\n"); } void getDiv(int num){ if(!divisor[num].empty()) return; if(num == 1){ divisor[num].push_back(1); return; } map<int, bool> marc; for(int i = sqrt(num); i > 1; i--){ if(num == i) continue; if(num % i) continue; if(divisor[i].empty() || divisor[num / i].empty()) continue; getDiv(i); getDiv(num / i); for(int j = 0; j < divisor[i].size(); j++){ for(int k = 0; k < divisor[num / i].size(); k++){ int val = divisor[i][j] * divisor[num / i][k]; if(marc[val]) continue; marc[val] = 1; divisor[num].push_back(val); } } return; } for(int i = sqrt(num); i > 1; i--){ if(num == i) continue; if(num % i) continue; if(divisor[i].empty() && divisor[num / i].empty()) continue; getDiv(i); getDiv(num / i); for(int j = 0; j < divisor[i].size(); j++){ for(int k = 0; k < divisor[num / i].size(); k++){ int val = divisor[i][j] * divisor[num / i][k]; if(marc[val]) continue; marc[val] = 1; divisor[num].push_back(val); } } return; } for(int i = sqrt(num); i > 1; i--){ if(num == i) continue; if(num % i) continue; getDiv(i); getDiv(num / i); for(int j = 0; j < divisor[i].size(); j++){ for(int k = 0; k < divisor[num / i].size(); k++){ int val = divisor[i][j] * divisor[num / i][k]; if(marc[val]) continue; marc[val] = 1; divisor[num].push_back(val); } } return; } divisor[num].push_back(1); divisor[num].push_back(num); } void calcDP(int num){ if(!dp[num].empty()) return; getDiv(num); dp[num].push_back(num - 1); map<int, bool> marc; for(int i = 0; i < divisor[num].size(); i++){ if(divisor[num][i] == num || divisor[num][i] == 1) continue; if(num / divisor[num][i] < divisor[num][i]) continue; int aux1, aux2; calcDP(divisor[num][i]); aux1 = divisor[num][i]; calcDP(num / divisor[num][i]); aux2 = num / divisor[num][i]; for(int i1 = 0; i1 < dp[aux1].size(); i1++){ for(int i2 = 0; i2 < dp[aux2].size(); i2++){ if(marc[dp[aux1][i1] + dp[aux2][i2]]) continue; dp[num].push_back(dp[aux1][i1] + dp[aux2][i2]); marc[dp[aux1][i1] + dp[aux2][i2]] = 1; } } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 512 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 0 ms | 256 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 1 ms | 256 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 0 ms | 256 KB | Output is correct |
23 | Correct | 0 ms | 256 KB | Output is correct |
24 | Correct | 1 ms | 256 KB | Output is correct |
25 | Correct | 1 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 512 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 0 ms | 256 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 1 ms | 256 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 0 ms | 256 KB | Output is correct |
23 | Correct | 0 ms | 256 KB | Output is correct |
24 | Correct | 1 ms | 256 KB | Output is correct |
25 | Correct | 1 ms | 256 KB | Output is correct |
26 | Correct | 3 ms | 384 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
31 | Correct | 3 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 384 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 0 ms | 256 KB | Output is correct |
35 | Correct | 1 ms | 256 KB | Output is correct |
36 | Correct | 1 ms | 384 KB | Output is correct |
37 | Correct | 2 ms | 384 KB | Output is correct |
38 | Correct | 1 ms | 384 KB | Output is correct |
39 | Correct | 1 ms | 256 KB | Output is correct |
40 | Correct | 2 ms | 384 KB | Output is correct |
41 | Correct | 0 ms | 256 KB | Output is correct |
42 | Correct | 1 ms | 256 KB | Output is correct |
43 | Correct | 1 ms | 256 KB | Output is correct |
44 | Correct | 1 ms | 256 KB | Output is correct |
45 | Correct | 1 ms | 384 KB | Output is correct |
46 | Correct | 1 ms | 256 KB | Output is correct |
47 | Correct | 2 ms | 384 KB | Output is correct |
48 | Correct | 1 ms | 256 KB | Output is correct |
49 | Correct | 1 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 512 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 0 ms | 256 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 1 ms | 256 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 0 ms | 256 KB | Output is correct |
23 | Correct | 0 ms | 256 KB | Output is correct |
24 | Correct | 1 ms | 256 KB | Output is correct |
25 | Correct | 1 ms | 256 KB | Output is correct |
26 | Correct | 3 ms | 384 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
31 | Correct | 3 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 384 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 0 ms | 256 KB | Output is correct |
35 | Correct | 1 ms | 256 KB | Output is correct |
36 | Correct | 1 ms | 384 KB | Output is correct |
37 | Correct | 2 ms | 384 KB | Output is correct |
38 | Correct | 1 ms | 384 KB | Output is correct |
39 | Correct | 1 ms | 256 KB | Output is correct |
40 | Correct | 2 ms | 384 KB | Output is correct |
41 | Correct | 0 ms | 256 KB | Output is correct |
42 | Correct | 1 ms | 256 KB | Output is correct |
43 | Correct | 1 ms | 256 KB | Output is correct |
44 | Correct | 1 ms | 256 KB | Output is correct |
45 | Correct | 1 ms | 384 KB | Output is correct |
46 | Correct | 1 ms | 256 KB | Output is correct |
47 | Correct | 2 ms | 384 KB | Output is correct |
48 | Correct | 1 ms | 256 KB | Output is correct |
49 | Correct | 1 ms | 384 KB | Output is correct |
50 | Correct | 10 ms | 416 KB | Output is correct |
51 | Correct | 8 ms | 384 KB | Output is correct |
52 | Correct | 9 ms | 384 KB | Output is correct |
53 | Correct | 9 ms | 384 KB | Output is correct |
54 | Correct | 4 ms | 384 KB | Output is correct |
55 | Correct | 16 ms | 512 KB | Output is correct |
56 | Correct | 15 ms | 384 KB | Output is correct |
57 | Correct | 13 ms | 384 KB | Output is correct |
58 | Correct | 0 ms | 384 KB | Output is correct |
59 | Correct | 1 ms | 256 KB | Output is correct |
60 | Correct | 1 ms | 384 KB | Output is correct |
61 | Correct | 7 ms | 384 KB | Output is correct |
62 | Correct | 3 ms | 384 KB | Output is correct |
63 | Correct | 2 ms | 384 KB | Output is correct |
64 | Correct | 0 ms | 384 KB | Output is correct |
65 | Correct | 6 ms | 384 KB | Output is correct |
66 | Correct | 1 ms | 256 KB | Output is correct |
67 | Correct | 1 ms | 256 KB | Output is correct |
68 | Correct | 1 ms | 256 KB | Output is correct |
69 | Correct | 1 ms | 384 KB | Output is correct |
70 | Correct | 3 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 512 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 0 ms | 256 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 1 ms | 256 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 0 ms | 256 KB | Output is correct |
23 | Correct | 0 ms | 256 KB | Output is correct |
24 | Correct | 1 ms | 256 KB | Output is correct |
25 | Correct | 1 ms | 256 KB | Output is correct |
26 | Correct | 3 ms | 384 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
31 | Correct | 3 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 384 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 0 ms | 256 KB | Output is correct |
35 | Correct | 1 ms | 256 KB | Output is correct |
36 | Correct | 1 ms | 384 KB | Output is correct |
37 | Correct | 2 ms | 384 KB | Output is correct |
38 | Correct | 1 ms | 384 KB | Output is correct |
39 | Correct | 1 ms | 256 KB | Output is correct |
40 | Correct | 2 ms | 384 KB | Output is correct |
41 | Correct | 0 ms | 256 KB | Output is correct |
42 | Correct | 1 ms | 256 KB | Output is correct |
43 | Correct | 1 ms | 256 KB | Output is correct |
44 | Correct | 1 ms | 256 KB | Output is correct |
45 | Correct | 1 ms | 384 KB | Output is correct |
46 | Correct | 1 ms | 256 KB | Output is correct |
47 | Correct | 2 ms | 384 KB | Output is correct |
48 | Correct | 1 ms | 256 KB | Output is correct |
49 | Correct | 1 ms | 384 KB | Output is correct |
50 | Correct | 10 ms | 416 KB | Output is correct |
51 | Correct | 8 ms | 384 KB | Output is correct |
52 | Correct | 9 ms | 384 KB | Output is correct |
53 | Correct | 9 ms | 384 KB | Output is correct |
54 | Correct | 4 ms | 384 KB | Output is correct |
55 | Correct | 16 ms | 512 KB | Output is correct |
56 | Correct | 15 ms | 384 KB | Output is correct |
57 | Correct | 13 ms | 384 KB | Output is correct |
58 | Correct | 0 ms | 384 KB | Output is correct |
59 | Correct | 1 ms | 256 KB | Output is correct |
60 | Correct | 1 ms | 384 KB | Output is correct |
61 | Correct | 7 ms | 384 KB | Output is correct |
62 | Correct | 3 ms | 384 KB | Output is correct |
63 | Correct | 2 ms | 384 KB | Output is correct |
64 | Correct | 0 ms | 384 KB | Output is correct |
65 | Correct | 6 ms | 384 KB | Output is correct |
66 | Correct | 1 ms | 256 KB | Output is correct |
67 | Correct | 1 ms | 256 KB | Output is correct |
68 | Correct | 1 ms | 256 KB | Output is correct |
69 | Correct | 1 ms | 384 KB | Output is correct |
70 | Correct | 3 ms | 384 KB | Output is correct |
71 | Correct | 2661 ms | 4508 KB | Output is correct |
72 | Correct | 1491 ms | 3576 KB | Output is correct |
73 | Correct | 2805 ms | 4072 KB | Output is correct |
74 | Correct | 1110 ms | 2936 KB | Output is correct |
75 | Correct | 1532 ms | 3260 KB | Output is correct |
76 | Execution timed out | 5062 ms | 5300 KB | Time limit exceeded |
77 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 1 ms | 512 KB | Output is correct |
5 | Correct | 1 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 0 ms | 256 KB | Output is correct |
9 | Correct | 1 ms | 256 KB | Output is correct |
10 | Correct | 0 ms | 256 KB | Output is correct |
11 | Correct | 0 ms | 256 KB | Output is correct |
12 | Correct | 0 ms | 256 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 256 KB | Output is correct |
15 | Correct | 1 ms | 256 KB | Output is correct |
16 | Correct | 0 ms | 256 KB | Output is correct |
17 | Correct | 0 ms | 256 KB | Output is correct |
18 | Correct | 0 ms | 256 KB | Output is correct |
19 | Correct | 0 ms | 256 KB | Output is correct |
20 | Correct | 1 ms | 256 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 0 ms | 256 KB | Output is correct |
23 | Correct | 0 ms | 256 KB | Output is correct |
24 | Correct | 1 ms | 256 KB | Output is correct |
25 | Correct | 1 ms | 256 KB | Output is correct |
26 | Correct | 3 ms | 384 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
31 | Correct | 3 ms | 384 KB | Output is correct |
32 | Correct | 2 ms | 384 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 0 ms | 256 KB | Output is correct |
35 | Correct | 1 ms | 256 KB | Output is correct |
36 | Correct | 1 ms | 384 KB | Output is correct |
37 | Correct | 2 ms | 384 KB | Output is correct |
38 | Correct | 1 ms | 384 KB | Output is correct |
39 | Correct | 1 ms | 256 KB | Output is correct |
40 | Correct | 2 ms | 384 KB | Output is correct |
41 | Correct | 0 ms | 256 KB | Output is correct |
42 | Correct | 1 ms | 256 KB | Output is correct |
43 | Correct | 1 ms | 256 KB | Output is correct |
44 | Correct | 1 ms | 256 KB | Output is correct |
45 | Correct | 1 ms | 384 KB | Output is correct |
46 | Correct | 1 ms | 256 KB | Output is correct |
47 | Correct | 2 ms | 384 KB | Output is correct |
48 | Correct | 1 ms | 256 KB | Output is correct |
49 | Correct | 1 ms | 384 KB | Output is correct |
50 | Correct | 10 ms | 416 KB | Output is correct |
51 | Correct | 8 ms | 384 KB | Output is correct |
52 | Correct | 9 ms | 384 KB | Output is correct |
53 | Correct | 9 ms | 384 KB | Output is correct |
54 | Correct | 4 ms | 384 KB | Output is correct |
55 | Correct | 16 ms | 512 KB | Output is correct |
56 | Correct | 15 ms | 384 KB | Output is correct |
57 | Correct | 13 ms | 384 KB | Output is correct |
58 | Correct | 0 ms | 384 KB | Output is correct |
59 | Correct | 1 ms | 256 KB | Output is correct |
60 | Correct | 1 ms | 384 KB | Output is correct |
61 | Correct | 7 ms | 384 KB | Output is correct |
62 | Correct | 3 ms | 384 KB | Output is correct |
63 | Correct | 2 ms | 384 KB | Output is correct |
64 | Correct | 0 ms | 384 KB | Output is correct |
65 | Correct | 6 ms | 384 KB | Output is correct |
66 | Correct | 1 ms | 256 KB | Output is correct |
67 | Correct | 1 ms | 256 KB | Output is correct |
68 | Correct | 1 ms | 256 KB | Output is correct |
69 | Correct | 1 ms | 384 KB | Output is correct |
70 | Correct | 3 ms | 384 KB | Output is correct |
71 | Correct | 2661 ms | 4508 KB | Output is correct |
72 | Correct | 1491 ms | 3576 KB | Output is correct |
73 | Correct | 2805 ms | 4072 KB | Output is correct |
74 | Correct | 1110 ms | 2936 KB | Output is correct |
75 | Correct | 1532 ms | 3260 KB | Output is correct |
76 | Execution timed out | 5062 ms | 5300 KB | Time limit exceeded |
77 | Halted | 0 ms | 0 KB | - |