Submission #619671

# Submission time Handle Problem Language Result Execution time Memory
619671 2022-08-02T14:23:46 Z Baray Toys (CEOI18_toy) C++17
100 / 100
3744 ms 114752 KB
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

#define pb push_back

int n;
vector<int> divisors;

int main() {
    cin >> n;

    for (int i = 1; i * i <= n; i++) {
        if (!(n % i))
            divisors.pb(i); if (i * i != n) divisors.pb(n / i);
    }

    sort(divisors.begin(), divisors.end());
    
    vector<vector<int> > v(divisors.size());

    v[0].pb(0);

    for (int i = 1; i < divisors.size(); i++) {
        for (int j = 0; j < i; j++) {
            if (!(divisors[i] % divisors[j])) {
                for (int x = 0; x < v[j].size(); x++) {
                    v[i].pb(v[j][x] + divisors[i] / divisors[j] - 1);
                }
            }
        }

        sort(v[i].begin(), v[i].end());
        v[i].resize(unique(v[i].begin(), v[i].end()) - v[i].begin());
    }

    cout << v.back().size() << "\n";
    for (int i = 0; i < v.back().size(); i++) {
        cout << v.back()[i] << " ";
    }
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:16:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   16 |         if (!(n % i))
      |         ^~
toy.cpp:17:29: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   17 |             divisors.pb(i); if (i * i != n) divisors.pb(n / i);
      |                             ^~
toy.cpp:26:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for (int i = 1; i < divisors.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~~~
toy.cpp:29:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |                 for (int x = 0; x < v[j].size(); x++) {
      |                                 ~~^~~~~~~~~~~~~
toy.cpp:40:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for (int i = 0; i < v.back().size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 304 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 336 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 0 ms 308 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 304 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 336 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 0 ms 308 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 308 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 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 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 1 ms 304 KB Output is correct
38 Correct 0 ms 212 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 468 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 304 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 336 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 0 ms 308 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 308 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 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 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 1 ms 304 KB Output is correct
38 Correct 0 ms 212 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 468 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 2 ms 468 KB Output is correct
51 Correct 2 ms 468 KB Output is correct
52 Correct 2 ms 468 KB Output is correct
53 Correct 2 ms 468 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 3 ms 564 KB Output is correct
56 Correct 3 ms 468 KB Output is correct
57 Correct 4 ms 464 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 304 KB Output is correct
60 Correct 1 ms 304 KB Output is correct
61 Correct 2 ms 340 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 340 KB Output is correct
65 Correct 2 ms 340 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 2 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 304 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 336 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 0 ms 308 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 308 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 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 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 1 ms 304 KB Output is correct
38 Correct 0 ms 212 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 468 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 2 ms 468 KB Output is correct
51 Correct 2 ms 468 KB Output is correct
52 Correct 2 ms 468 KB Output is correct
53 Correct 2 ms 468 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 3 ms 564 KB Output is correct
56 Correct 3 ms 468 KB Output is correct
57 Correct 4 ms 464 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 304 KB Output is correct
60 Correct 1 ms 304 KB Output is correct
61 Correct 2 ms 340 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 340 KB Output is correct
65 Correct 2 ms 340 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 2 ms 308 KB Output is correct
71 Correct 375 ms 18780 KB Output is correct
72 Correct 300 ms 14088 KB Output is correct
73 Correct 278 ms 18044 KB Output is correct
74 Correct 193 ms 10032 KB Output is correct
75 Correct 199 ms 11656 KB Output is correct
76 Correct 520 ms 28124 KB Output is correct
77 Correct 465 ms 26104 KB Output is correct
78 Correct 431 ms 22204 KB Output is correct
79 Correct 426 ms 22588 KB Output is correct
80 Correct 239 ms 948 KB Output is correct
81 Correct 240 ms 896 KB Output is correct
82 Correct 163 ms 1184 KB Output is correct
83 Correct 176 ms 3720 KB Output is correct
84 Correct 101 ms 4156 KB Output is correct
85 Correct 250 ms 2088 KB Output is correct
86 Correct 246 ms 1060 KB Output is correct
87 Correct 260 ms 5020 KB Output is correct
88 Correct 244 ms 1020 KB Output is correct
89 Correct 242 ms 956 KB Output is correct
90 Correct 245 ms 1216 KB Output is correct
91 Correct 264 ms 2384 KB Output is correct
92 Correct 305 ms 5176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 300 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 304 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 304 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 336 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 1 ms 304 KB Output is correct
22 Correct 0 ms 308 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 308 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 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 0 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 1 ms 304 KB Output is correct
38 Correct 0 ms 212 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 468 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 2 ms 468 KB Output is correct
51 Correct 2 ms 468 KB Output is correct
52 Correct 2 ms 468 KB Output is correct
53 Correct 2 ms 468 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 3 ms 564 KB Output is correct
56 Correct 3 ms 468 KB Output is correct
57 Correct 4 ms 464 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 304 KB Output is correct
60 Correct 1 ms 304 KB Output is correct
61 Correct 2 ms 340 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 340 KB Output is correct
65 Correct 2 ms 340 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 1 ms 212 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 2 ms 308 KB Output is correct
71 Correct 375 ms 18780 KB Output is correct
72 Correct 300 ms 14088 KB Output is correct
73 Correct 278 ms 18044 KB Output is correct
74 Correct 193 ms 10032 KB Output is correct
75 Correct 199 ms 11656 KB Output is correct
76 Correct 520 ms 28124 KB Output is correct
77 Correct 465 ms 26104 KB Output is correct
78 Correct 431 ms 22204 KB Output is correct
79 Correct 426 ms 22588 KB Output is correct
80 Correct 239 ms 948 KB Output is correct
81 Correct 240 ms 896 KB Output is correct
82 Correct 163 ms 1184 KB Output is correct
83 Correct 176 ms 3720 KB Output is correct
84 Correct 101 ms 4156 KB Output is correct
85 Correct 250 ms 2088 KB Output is correct
86 Correct 246 ms 1060 KB Output is correct
87 Correct 260 ms 5020 KB Output is correct
88 Correct 244 ms 1020 KB Output is correct
89 Correct 242 ms 956 KB Output is correct
90 Correct 245 ms 1216 KB Output is correct
91 Correct 264 ms 2384 KB Output is correct
92 Correct 305 ms 5176 KB Output is correct
93 Correct 2865 ms 94732 KB Output is correct
94 Correct 2314 ms 55108 KB Output is correct
95 Correct 2095 ms 66216 KB Output is correct
96 Correct 1573 ms 55632 KB Output is correct
97 Correct 1335 ms 51688 KB Output is correct
98 Correct 3744 ms 109284 KB Output is correct
99 Correct 3555 ms 114752 KB Output is correct
100 Correct 3329 ms 107228 KB Output is correct
101 Correct 3435 ms 103316 KB Output is correct
102 Correct 2977 ms 90916 KB Output is correct
103 Correct 2778 ms 74224 KB Output is correct
104 Correct 2376 ms 2396 KB Output is correct
105 Correct 2356 ms 2524 KB Output is correct
106 Correct 1313 ms 2880 KB Output is correct
107 Correct 1821 ms 11144 KB Output is correct
108 Correct 1960 ms 23144 KB Output is correct
109 Correct 2396 ms 5416 KB Output is correct
110 Correct 2364 ms 2640 KB Output is correct
111 Correct 2310 ms 14368 KB Output is correct
112 Correct 2394 ms 2536 KB Output is correct
113 Correct 2360 ms 2368 KB Output is correct
114 Correct 2399 ms 3784 KB Output is correct
115 Correct 2428 ms 2300 KB Output is correct
116 Correct 2400 ms 5068 KB Output is correct
117 Correct 2408 ms 21608 KB Output is correct