Submission #491001

# Submission time Handle Problem Language Result Execution time Memory
491001 2021-11-30T03:12:50 Z baokhue232005 Toys (CEOI18_toy) C++17
100 / 100
616 ms 60156 KB
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
// lethal option

#include<bits/stdc++.h>
using namespace std;

#define all(flg) flg.begin(), flg.end()
#define int long long
#define pb push_back
#define fi first
#define se second
// #define endl "\n"
#define eb emplace_back
#define ii pair<int, int>
#define PI 3.141592653589793238462643383279502884
#define ll long long
#define for1(i, ff, gg) for(int i = ff; i <= gg; ++i)
#define for2(i, ff, gg) for(int i = ff; i >= gg; --i)
const ll mod = 1e9 + 7;
const int maxN = 300005;
const ll oo = 1e18 + 7;
int n, a[maxN];
int x, y, z, k;

vector<int> ans;

vector<int> back(int god, int dnlim, int sum){
    vector<int> buo;
    int db = sqrt(god);
    if(dnlim > god) return buo;
    buo.pb(sum + god - 1);
    for1(i, dnlim, db) if(god % i == 0){
        auto cm = back(god / i, i, sum + i - 1);

        buo.insert(buo.end(), all(cm));
    }
    // cout << god << " " << dnlim << ' ' << sum << "\n";
    // for(int cc : buo) cout << cc << " ";
    // cout << endl;
    return buo;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    if(n == 1){
        cout << "1\n0\n"; return 0;
    }
    ans = back(n, 2, 0);
    sort(all(ans));
    int vl = 0;
    for1(i, 0, ans.size() - 1){
        if(i == 0 || ans[i] != ans[i - 1]) ++vl;
    }
    cout << vl << endl;
    for1(i, 0, ans.size() - 1){
        if(i == 0 || ans[i] != ans[i - 1]) cout << ans[i] << " ";
    }
    cout << endl;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:21:43: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 | #define for1(i, ff, gg) for(int i = ff; i <= gg; ++i)
......
   58 |     for1(i, 0, ans.size() - 1){
      |          ~~~~~~~~~~~~~~~~~~~~              
toy.cpp:58:5: note: in expansion of macro 'for1'
   58 |     for1(i, 0, ans.size() - 1){
      |     ^~~~
toy.cpp:21:43: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 | #define for1(i, ff, gg) for(int i = ff; i <= gg; ++i)
......
   62 |     for1(i, 0, ans.size() - 1){
      |          ~~~~~~~~~~~~~~~~~~~~              
toy.cpp:62:5: note: in expansion of macro 'for1'
   62 |     for1(i, 0, ans.size() - 1){
      |     ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 0 ms 332 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 0 ms 332 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 0 ms 332 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 0 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 0 ms 204 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 0 ms 332 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 0 ms 332 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 0 ms 332 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 0 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 0 ms 204 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 1 ms 332 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 0 ms 204 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 0 ms 204 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 1 ms 332 KB Output is correct
66 Correct 0 ms 204 KB Output is correct
67 Correct 0 ms 204 KB Output is correct
68 Correct 0 ms 204 KB Output is correct
69 Correct 0 ms 204 KB Output is correct
70 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 0 ms 332 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 0 ms 332 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 0 ms 332 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 0 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 0 ms 204 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 1 ms 332 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 0 ms 204 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 0 ms 204 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 1 ms 332 KB Output is correct
66 Correct 0 ms 204 KB Output is correct
67 Correct 0 ms 204 KB Output is correct
68 Correct 0 ms 204 KB Output is correct
69 Correct 0 ms 204 KB Output is correct
70 Correct 0 ms 204 KB Output is correct
71 Correct 53 ms 5204 KB Output is correct
72 Correct 37 ms 3084 KB Output is correct
73 Correct 55 ms 4972 KB Output is correct
74 Correct 25 ms 2588 KB Output is correct
75 Correct 34 ms 3600 KB Output is correct
76 Correct 103 ms 8860 KB Output is correct
77 Correct 117 ms 10400 KB Output is correct
78 Correct 80 ms 7056 KB Output is correct
79 Correct 80 ms 6520 KB Output is correct
80 Correct 0 ms 204 KB Output is correct
81 Correct 0 ms 204 KB Output is correct
82 Correct 1 ms 332 KB Output is correct
83 Correct 14 ms 1352 KB Output is correct
84 Correct 12 ms 1464 KB Output is correct
85 Correct 4 ms 460 KB Output is correct
86 Correct 1 ms 204 KB Output is correct
87 Correct 17 ms 1140 KB Output is correct
88 Correct 1 ms 204 KB Output is correct
89 Correct 0 ms 204 KB Output is correct
90 Correct 1 ms 204 KB Output is correct
91 Correct 5 ms 460 KB Output is correct
92 Correct 13 ms 1168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
26 Correct 0 ms 332 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 0 ms 332 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 0 ms 332 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 0 ms 204 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 0 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 0 ms 204 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 1 ms 332 KB Output is correct
56 Correct 1 ms 332 KB Output is correct
57 Correct 1 ms 332 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 0 ms 204 KB Output is correct
61 Correct 1 ms 332 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 0 ms 204 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 1 ms 332 KB Output is correct
66 Correct 0 ms 204 KB Output is correct
67 Correct 0 ms 204 KB Output is correct
68 Correct 0 ms 204 KB Output is correct
69 Correct 0 ms 204 KB Output is correct
70 Correct 0 ms 204 KB Output is correct
71 Correct 53 ms 5204 KB Output is correct
72 Correct 37 ms 3084 KB Output is correct
73 Correct 55 ms 4972 KB Output is correct
74 Correct 25 ms 2588 KB Output is correct
75 Correct 34 ms 3600 KB Output is correct
76 Correct 103 ms 8860 KB Output is correct
77 Correct 117 ms 10400 KB Output is correct
78 Correct 80 ms 7056 KB Output is correct
79 Correct 80 ms 6520 KB Output is correct
80 Correct 0 ms 204 KB Output is correct
81 Correct 0 ms 204 KB Output is correct
82 Correct 1 ms 332 KB Output is correct
83 Correct 14 ms 1352 KB Output is correct
84 Correct 12 ms 1464 KB Output is correct
85 Correct 4 ms 460 KB Output is correct
86 Correct 1 ms 204 KB Output is correct
87 Correct 17 ms 1140 KB Output is correct
88 Correct 1 ms 204 KB Output is correct
89 Correct 0 ms 204 KB Output is correct
90 Correct 1 ms 204 KB Output is correct
91 Correct 5 ms 460 KB Output is correct
92 Correct 13 ms 1168 KB Output is correct
93 Correct 423 ms 41144 KB Output is correct
94 Correct 192 ms 13144 KB Output is correct
95 Correct 236 ms 19492 KB Output is correct
96 Correct 207 ms 19516 KB Output is correct
97 Correct 195 ms 13296 KB Output is correct
98 Correct 522 ms 34176 KB Output is correct
99 Correct 616 ms 60156 KB Output is correct
100 Correct 517 ms 34164 KB Output is correct
101 Correct 612 ms 49992 KB Output is correct
102 Correct 519 ms 39380 KB Output is correct
103 Correct 302 ms 26084 KB Output is correct
104 Correct 1 ms 204 KB Output is correct
105 Correct 1 ms 204 KB Output is correct
106 Correct 4 ms 460 KB Output is correct
107 Correct 65 ms 4324 KB Output is correct
108 Correct 121 ms 10244 KB Output is correct
109 Correct 14 ms 664 KB Output is correct
110 Correct 1 ms 204 KB Output is correct
111 Correct 69 ms 2500 KB Output is correct
112 Correct 1 ms 204 KB Output is correct
113 Correct 1 ms 204 KB Output is correct
114 Correct 5 ms 332 KB Output is correct
115 Correct 0 ms 204 KB Output is correct
116 Correct 14 ms 452 KB Output is correct
117 Correct 69 ms 2888 KB Output is correct