Submission #528981

# Submission time Handle Problem Language Result Execution time Memory
528981 2022-02-21T20:57:02 Z Lobo Toys (CEOI18_toy) C++17
100 / 100
1199 ms 131904 KB
#include<bits/stdc++.h>
using namespace std;

const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()

#define maxn 

vector<int> dv, ans;
set<pair<int,pair<int,int>>> ss;

void br(int s, int n, int id) {
    // cout << s << " " << n << " " << id << endl;
    if(n == 1) {
        ans.pb(s);
    }
    if(id == dv.size()) return;

    br(s,n,id+1);
    if(n%dv[id] == 0) br(s+dv[id]-1,n/dv[id],id);
}

void solve() {
    int n;
    cin >> n;
    if(n == 1) {
        cout << 1 << endl << 0 << endl;
        return;
    }
    dv.pb(n);
    for(int i = 2; i*i <= n; i++) {
        if(n%i == 0) {
            dv.pb(i);
            if(n/i != i) dv.pb(n/i);
        }
    }
    sort(all(dv), greater<int>());
    dv.erase(unique(all(dv)),dv.end());

    br(0,n,0);

    sort(all(ans));
    ans.erase(unique(all(ans)),ans.end());
    cout << ans.size() << endl;
    for(auto x : ans) cout << x << " ";
    cout << endl;
}

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);

    // freopen("in.in", "r", stdin);
    //freopen("out.out", "w", stdout);

    int tt = 1;
    // cin >> tt;
    while(tt--) solve();

}

Compilation message

toy.cpp: In function 'void br(long long int, long long int, long long int)':
toy.cpp:25:11: 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]
   25 |     if(id == dv.size()) return;
      |        ~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 312 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 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 312 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 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 0 ms 312 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 0 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 312 KB Output is correct
42 Correct 1 ms 308 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 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 312 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 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 0 ms 312 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 0 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 312 KB Output is correct
42 Correct 1 ms 308 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 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 2 ms 448 KB Output is correct
51 Correct 1 ms 460 KB Output is correct
52 Correct 1 ms 460 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 316 KB Output is correct
55 Correct 2 ms 444 KB Output is correct
56 Correct 2 ms 460 KB Output is correct
57 Correct 2 ms 460 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 1 ms 204 KB Output is correct
60 Correct 1 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 1 ms 332 KB Output is correct
64 Correct 1 ms 204 KB Output is correct
65 Correct 1 ms 332 KB Output is correct
66 Correct 1 ms 204 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 1 ms 204 KB Output is correct
70 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 312 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 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 0 ms 312 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 0 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 312 KB Output is correct
42 Correct 1 ms 308 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 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 2 ms 448 KB Output is correct
51 Correct 1 ms 460 KB Output is correct
52 Correct 1 ms 460 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 316 KB Output is correct
55 Correct 2 ms 444 KB Output is correct
56 Correct 2 ms 460 KB Output is correct
57 Correct 2 ms 460 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 1 ms 204 KB Output is correct
60 Correct 1 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 1 ms 332 KB Output is correct
64 Correct 1 ms 204 KB Output is correct
65 Correct 1 ms 332 KB Output is correct
66 Correct 1 ms 204 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 1 ms 204 KB Output is correct
70 Correct 1 ms 332 KB Output is correct
71 Correct 119 ms 16944 KB Output is correct
72 Correct 79 ms 8608 KB Output is correct
73 Correct 115 ms 16804 KB Output is correct
74 Correct 63 ms 8584 KB Output is correct
75 Correct 79 ms 8636 KB Output is correct
76 Correct 209 ms 33304 KB Output is correct
77 Correct 219 ms 33324 KB Output is correct
78 Correct 201 ms 16860 KB Output is correct
79 Correct 147 ms 16876 KB Output is correct
80 Correct 1 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 12 ms 2504 KB Output is correct
84 Correct 15 ms 2500 KB Output is correct
85 Correct 2 ms 592 KB Output is correct
86 Correct 1 ms 204 KB Output is correct
87 Correct 16 ms 2452 KB Output is correct
88 Correct 1 ms 204 KB Output is correct
89 Correct 1 ms 204 KB Output is correct
90 Correct 1 ms 204 KB Output is correct
91 Correct 5 ms 972 KB Output is correct
92 Correct 30 ms 4572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 312 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 0 ms 312 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 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 0 ms 312 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 0 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 312 KB Output is correct
42 Correct 1 ms 308 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 1 ms 204 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 2 ms 448 KB Output is correct
51 Correct 1 ms 460 KB Output is correct
52 Correct 1 ms 460 KB Output is correct
53 Correct 1 ms 332 KB Output is correct
54 Correct 1 ms 316 KB Output is correct
55 Correct 2 ms 444 KB Output is correct
56 Correct 2 ms 460 KB Output is correct
57 Correct 2 ms 460 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 1 ms 204 KB Output is correct
60 Correct 1 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 1 ms 332 KB Output is correct
64 Correct 1 ms 204 KB Output is correct
65 Correct 1 ms 332 KB Output is correct
66 Correct 1 ms 204 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 1 ms 204 KB Output is correct
69 Correct 1 ms 204 KB Output is correct
70 Correct 1 ms 332 KB Output is correct
71 Correct 119 ms 16944 KB Output is correct
72 Correct 79 ms 8608 KB Output is correct
73 Correct 115 ms 16804 KB Output is correct
74 Correct 63 ms 8584 KB Output is correct
75 Correct 79 ms 8636 KB Output is correct
76 Correct 209 ms 33304 KB Output is correct
77 Correct 219 ms 33324 KB Output is correct
78 Correct 201 ms 16860 KB Output is correct
79 Correct 147 ms 16876 KB Output is correct
80 Correct 1 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 12 ms 2504 KB Output is correct
84 Correct 15 ms 2500 KB Output is correct
85 Correct 2 ms 592 KB Output is correct
86 Correct 1 ms 204 KB Output is correct
87 Correct 16 ms 2452 KB Output is correct
88 Correct 1 ms 204 KB Output is correct
89 Correct 1 ms 204 KB Output is correct
90 Correct 1 ms 204 KB Output is correct
91 Correct 5 ms 972 KB Output is correct
92 Correct 30 ms 4572 KB Output is correct
93 Correct 888 ms 131856 KB Output is correct
94 Correct 438 ms 66200 KB Output is correct
95 Correct 583 ms 66132 KB Output is correct
96 Correct 514 ms 66184 KB Output is correct
97 Correct 408 ms 66052 KB Output is correct
98 Correct 1004 ms 131904 KB Output is correct
99 Correct 1199 ms 131764 KB Output is correct
100 Correct 983 ms 131892 KB Output is correct
101 Correct 1048 ms 131824 KB Output is correct
102 Correct 871 ms 131796 KB Output is correct
103 Correct 545 ms 66164 KB Output is correct
104 Correct 1 ms 204 KB Output is correct
105 Correct 1 ms 320 KB Output is correct
106 Correct 2 ms 440 KB Output is correct
107 Correct 54 ms 8624 KB Output is correct
108 Correct 135 ms 16840 KB Output is correct
109 Correct 7 ms 1484 KB Output is correct
110 Correct 1 ms 204 KB Output is correct
111 Correct 45 ms 8664 KB Output is correct
112 Correct 1 ms 204 KB Output is correct
113 Correct 1 ms 204 KB Output is correct
114 Correct 3 ms 716 KB Output is correct
115 Correct 1 ms 316 KB Output is correct
116 Correct 3 ms 716 KB Output is correct
117 Correct 161 ms 16900 KB Output is correct