답안 #528972

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
528972 2022-02-21T20:50:57 Z Lobo Toys (CEOI18_toy) C++17
100 / 100
717 ms 33476 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);
        return;
    }
    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;
    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:26: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]
   26 |     if(id == dv.size()) return;
      |        ~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 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 312 KB Output is correct
16 Correct 0 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 204 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 0 ms 204 KB Output is correct
25 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 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 312 KB Output is correct
16 Correct 0 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 204 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 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 204 KB Output is correct
27 Correct 1 ms 204 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 204 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 1 ms 308 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 1 ms 316 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 1 ms 320 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 308 KB Output is correct
45 Correct 0 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 0 ms 308 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 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 312 KB Output is correct
16 Correct 0 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 204 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 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 204 KB Output is correct
27 Correct 1 ms 204 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 204 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 1 ms 308 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 1 ms 316 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 1 ms 320 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 308 KB Output is correct
45 Correct 0 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 0 ms 308 KB Output is correct
48 Correct 1 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 204 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 312 KB Output is correct
58 Correct 1 ms 204 KB Output is correct
59 Correct 1 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 204 KB Output is correct
63 Correct 1 ms 204 KB Output is correct
64 Correct 1 ms 312 KB Output is correct
65 Correct 1 ms 332 KB Output is correct
66 Correct 1 ms 256 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 0 ms 204 KB Output is correct
69 Correct 1 ms 204 KB Output is correct
70 Correct 1 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 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 312 KB Output is correct
16 Correct 0 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 204 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 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 204 KB Output is correct
27 Correct 1 ms 204 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 204 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 1 ms 308 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 1 ms 316 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 1 ms 320 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 308 KB Output is correct
45 Correct 0 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 0 ms 308 KB Output is correct
48 Correct 1 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 204 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 312 KB Output is correct
58 Correct 1 ms 204 KB Output is correct
59 Correct 1 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 204 KB Output is correct
63 Correct 1 ms 204 KB Output is correct
64 Correct 1 ms 312 KB Output is correct
65 Correct 1 ms 332 KB Output is correct
66 Correct 1 ms 256 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 0 ms 204 KB Output is correct
69 Correct 1 ms 204 KB Output is correct
70 Correct 1 ms 312 KB Output is correct
71 Correct 75 ms 4548 KB Output is correct
72 Correct 51 ms 2492 KB Output is correct
73 Correct 71 ms 4516 KB Output is correct
74 Correct 36 ms 1488 KB Output is correct
75 Correct 44 ms 2484 KB Output is correct
76 Correct 133 ms 8768 KB Output is correct
77 Correct 127 ms 8584 KB Output is correct
78 Correct 95 ms 4540 KB Output is correct
79 Correct 94 ms 4464 KB Output is correct
80 Correct 1 ms 204 KB Output is correct
81 Correct 0 ms 312 KB Output is correct
82 Correct 1 ms 332 KB Output is correct
83 Correct 7 ms 848 KB Output is correct
84 Correct 10 ms 972 KB Output is correct
85 Correct 2 ms 460 KB Output is correct
86 Correct 1 ms 204 KB Output is correct
87 Correct 10 ms 952 KB Output is correct
88 Correct 1 ms 204 KB Output is correct
89 Correct 0 ms 312 KB Output is correct
90 Correct 1 ms 204 KB Output is correct
91 Correct 3 ms 460 KB Output is correct
92 Correct 18 ms 944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 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 312 KB Output is correct
16 Correct 0 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 204 KB Output is correct
20 Correct 1 ms 312 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 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 204 KB Output is correct
27 Correct 1 ms 204 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 204 KB Output is correct
32 Correct 0 ms 204 KB Output is correct
33 Correct 1 ms 308 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 1 ms 316 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 1 ms 320 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 308 KB Output is correct
45 Correct 0 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 0 ms 308 KB Output is correct
48 Correct 1 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 204 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 312 KB Output is correct
58 Correct 1 ms 204 KB Output is correct
59 Correct 1 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 204 KB Output is correct
63 Correct 1 ms 204 KB Output is correct
64 Correct 1 ms 312 KB Output is correct
65 Correct 1 ms 332 KB Output is correct
66 Correct 1 ms 256 KB Output is correct
67 Correct 1 ms 204 KB Output is correct
68 Correct 0 ms 204 KB Output is correct
69 Correct 1 ms 204 KB Output is correct
70 Correct 1 ms 312 KB Output is correct
71 Correct 75 ms 4548 KB Output is correct
72 Correct 51 ms 2492 KB Output is correct
73 Correct 71 ms 4516 KB Output is correct
74 Correct 36 ms 1488 KB Output is correct
75 Correct 44 ms 2484 KB Output is correct
76 Correct 133 ms 8768 KB Output is correct
77 Correct 127 ms 8584 KB Output is correct
78 Correct 95 ms 4540 KB Output is correct
79 Correct 94 ms 4464 KB Output is correct
80 Correct 1 ms 204 KB Output is correct
81 Correct 0 ms 312 KB Output is correct
82 Correct 1 ms 332 KB Output is correct
83 Correct 7 ms 848 KB Output is correct
84 Correct 10 ms 972 KB Output is correct
85 Correct 2 ms 460 KB Output is correct
86 Correct 1 ms 204 KB Output is correct
87 Correct 10 ms 952 KB Output is correct
88 Correct 1 ms 204 KB Output is correct
89 Correct 0 ms 312 KB Output is correct
90 Correct 1 ms 204 KB Output is correct
91 Correct 3 ms 460 KB Output is correct
92 Correct 18 ms 944 KB Output is correct
93 Correct 525 ms 16936 KB Output is correct
94 Correct 253 ms 8616 KB Output is correct
95 Correct 314 ms 16836 KB Output is correct
96 Correct 272 ms 8712 KB Output is correct
97 Correct 235 ms 8688 KB Output is correct
98 Correct 597 ms 33476 KB Output is correct
99 Correct 717 ms 33392 KB Output is correct
100 Correct 588 ms 33308 KB Output is correct
101 Correct 623 ms 33348 KB Output is correct
102 Correct 525 ms 33292 KB Output is correct
103 Correct 331 ms 16928 KB Output is correct
104 Correct 1 ms 204 KB Output is correct
105 Correct 1 ms 204 KB Output is correct
106 Correct 1 ms 312 KB Output is correct
107 Correct 31 ms 2544 KB Output is correct
108 Correct 77 ms 4512 KB Output is correct
109 Correct 4 ms 592 KB Output is correct
110 Correct 1 ms 308 KB Output is correct
111 Correct 28 ms 2440 KB Output is correct
112 Correct 1 ms 204 KB Output is correct
113 Correct 1 ms 204 KB Output is correct
114 Correct 2 ms 332 KB Output is correct
115 Correct 1 ms 204 KB Output is correct
116 Correct 2 ms 460 KB Output is correct
117 Correct 86 ms 2496 KB Output is correct