Submission #572040

# Submission time Handle Problem Language Result Execution time Memory
572040 2022-06-03T12:13:34 Z piOOE Toys (CEOI18_toy) C++17
100 / 100
1743 ms 86488 KB
#include <bits/stdc++.h>

using namespace std;

#define sz(x) ((int)size(x))
#define all(x) begin(x), end(x)
#define trace(x) cout << #x << ": " << (x) << endl;

typedef long long ll;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int rand(int l, int r) { return (int) ((ll) rnd() % (r - l + 1)) + l; }

const int N = 10000;
const ll infL = 3e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    if (n == 1) {
        cout << "1\n0";
        return 0;
    }
    vector<int> div;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            div.push_back(i);
            div.push_back(n / i);
        }
    }
    sort(all(div));
    div.resize(unique(all(div)) - begin(div));
    int m = sz(div);
    vector<set<int>> st(m);
    for (int i = 1; i < m; ++i) {
        int x = div[i];
        st[i].insert(x - 1);
        for (int j = i - 1; j > 0; --j) {
            int y = div[j];
            if (x % y == 0) {
                int z = x / y;
                for (int u : st[j])
                    st[i].insert(z - 1 + u);
            }
        }
    }
    cout << sz(st[m - 1]) << '\n';
    for (int x : st[m - 1])
        cout << x << " ";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 280 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 328 KB Output is correct
16 Correct 0 ms 324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 280 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 328 KB Output is correct
16 Correct 0 ms 324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 328 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 328 KB Output is correct
35 Correct 0 ms 328 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 0 ms 328 KB Output is correct
43 Correct 0 ms 324 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 324 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 280 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 328 KB Output is correct
16 Correct 0 ms 324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 328 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 328 KB Output is correct
35 Correct 0 ms 328 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 0 ms 328 KB Output is correct
43 Correct 0 ms 324 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 324 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 3 ms 580 KB Output is correct
51 Correct 2 ms 584 KB Output is correct
52 Correct 2 ms 468 KB Output is correct
53 Correct 3 ms 468 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 4 ms 596 KB Output is correct
56 Correct 3 ms 596 KB Output is correct
57 Correct 3 ms 596 KB Output is correct
58 Correct 0 ms 328 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 2 ms 468 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 324 KB Output is correct
64 Correct 0 ms 212 KB Output is correct
65 Correct 2 ms 468 KB Output is correct
66 Correct 0 ms 212 KB Output is correct
67 Correct 0 ms 212 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 324 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 280 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 328 KB Output is correct
16 Correct 0 ms 324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 328 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 328 KB Output is correct
35 Correct 0 ms 328 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 0 ms 328 KB Output is correct
43 Correct 0 ms 324 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 324 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 3 ms 580 KB Output is correct
51 Correct 2 ms 584 KB Output is correct
52 Correct 2 ms 468 KB Output is correct
53 Correct 3 ms 468 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 4 ms 596 KB Output is correct
56 Correct 3 ms 596 KB Output is correct
57 Correct 3 ms 596 KB Output is correct
58 Correct 0 ms 328 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 2 ms 468 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 324 KB Output is correct
64 Correct 0 ms 212 KB Output is correct
65 Correct 2 ms 468 KB Output is correct
66 Correct 0 ms 212 KB Output is correct
67 Correct 0 ms 212 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 324 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
71 Correct 248 ms 18412 KB Output is correct
72 Correct 165 ms 13984 KB Output is correct
73 Correct 234 ms 16388 KB Output is correct
74 Correct 129 ms 11064 KB Output is correct
75 Correct 142 ms 11764 KB Output is correct
76 Correct 428 ms 24884 KB Output is correct
77 Correct 333 ms 21912 KB Output is correct
78 Correct 321 ms 20656 KB Output is correct
79 Correct 287 ms 19960 KB Output is correct
80 Correct 1 ms 212 KB Output is correct
81 Correct 1 ms 212 KB Output is correct
82 Correct 3 ms 596 KB Output is correct
83 Correct 32 ms 3520 KB Output is correct
84 Correct 41 ms 4316 KB Output is correct
85 Correct 10 ms 1492 KB Output is correct
86 Correct 1 ms 340 KB Output is correct
87 Correct 50 ms 4944 KB Output is correct
88 Correct 1 ms 212 KB Output is correct
89 Correct 1 ms 332 KB Output is correct
90 Correct 1 ms 328 KB Output is correct
91 Correct 15 ms 2132 KB Output is correct
92 Correct 57 ms 6476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 280 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 328 KB Output is correct
16 Correct 0 ms 324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 328 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 1 ms 328 KB Output is correct
35 Correct 0 ms 328 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 0 ms 328 KB Output is correct
43 Correct 0 ms 324 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 324 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 3 ms 580 KB Output is correct
51 Correct 2 ms 584 KB Output is correct
52 Correct 2 ms 468 KB Output is correct
53 Correct 3 ms 468 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 4 ms 596 KB Output is correct
56 Correct 3 ms 596 KB Output is correct
57 Correct 3 ms 596 KB Output is correct
58 Correct 0 ms 328 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 2 ms 468 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 324 KB Output is correct
64 Correct 0 ms 212 KB Output is correct
65 Correct 2 ms 468 KB Output is correct
66 Correct 0 ms 212 KB Output is correct
67 Correct 0 ms 212 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 324 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
71 Correct 248 ms 18412 KB Output is correct
72 Correct 165 ms 13984 KB Output is correct
73 Correct 234 ms 16388 KB Output is correct
74 Correct 129 ms 11064 KB Output is correct
75 Correct 142 ms 11764 KB Output is correct
76 Correct 428 ms 24884 KB Output is correct
77 Correct 333 ms 21912 KB Output is correct
78 Correct 321 ms 20656 KB Output is correct
79 Correct 287 ms 19960 KB Output is correct
80 Correct 1 ms 212 KB Output is correct
81 Correct 1 ms 212 KB Output is correct
82 Correct 3 ms 596 KB Output is correct
83 Correct 32 ms 3520 KB Output is correct
84 Correct 41 ms 4316 KB Output is correct
85 Correct 10 ms 1492 KB Output is correct
86 Correct 1 ms 340 KB Output is correct
87 Correct 50 ms 4944 KB Output is correct
88 Correct 1 ms 212 KB Output is correct
89 Correct 1 ms 332 KB Output is correct
90 Correct 1 ms 328 KB Output is correct
91 Correct 15 ms 2132 KB Output is correct
92 Correct 57 ms 6476 KB Output is correct
93 Correct 1491 ms 77264 KB Output is correct
94 Correct 859 ms 51908 KB Output is correct
95 Correct 929 ms 54588 KB Output is correct
96 Correct 812 ms 48700 KB Output is correct
97 Correct 763 ms 44364 KB Output is correct
98 Correct 1688 ms 85216 KB Output is correct
99 Correct 1743 ms 86488 KB Output is correct
100 Correct 1678 ms 83516 KB Output is correct
101 Correct 1539 ms 76968 KB Output is correct
102 Correct 1378 ms 69344 KB Output is correct
103 Correct 1119 ms 62296 KB Output is correct
104 Correct 1 ms 212 KB Output is correct
105 Correct 1 ms 212 KB Output is correct
106 Correct 5 ms 852 KB Output is correct
107 Correct 110 ms 9420 KB Output is correct
108 Correct 321 ms 20392 KB Output is correct
109 Correct 29 ms 3124 KB Output is correct
110 Correct 1 ms 212 KB Output is correct
111 Correct 142 ms 12100 KB Output is correct
112 Correct 1 ms 212 KB Output is correct
113 Correct 1 ms 212 KB Output is correct
114 Correct 4 ms 872 KB Output is correct
115 Correct 1 ms 212 KB Output is correct
116 Correct 11 ms 1580 KB Output is correct
117 Correct 304 ms 24604 KB Output is correct