답안 #528966

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
528966 2022-02-21T20:46:04 Z Lobo Toys (CEOI18_toy) C++17
59 / 100
1006 ms 262148 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(ss.count(mp(s,mp(n,id)))) return;
    ss.insert(mp(s,mp(n,id)));
    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));
    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:28: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]
   28 |     if(id == dv.size()) return;
      |        ~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 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 1 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 1 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 0 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 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 1 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 0 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 1 ms 204 KB Output is correct
26 Correct 15 ms 3540 KB Output is correct
27 Correct 11 ms 2928 KB Output is correct
28 Correct 6 ms 1356 KB Output is correct
29 Correct 4 ms 972 KB Output is correct
30 Correct 2 ms 588 KB Output is correct
31 Correct 19 ms 3896 KB Output is correct
32 Correct 12 ms 3020 KB Output is correct
33 Correct 12 ms 3020 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 460 KB Output is correct
37 Correct 8 ms 1608 KB Output is correct
38 Correct 2 ms 588 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 7 ms 1996 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 2 ms 588 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 6 ms 1356 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 2 ms 460 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 1 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 0 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 1 ms 204 KB Output is correct
26 Correct 15 ms 3540 KB Output is correct
27 Correct 11 ms 2928 KB Output is correct
28 Correct 6 ms 1356 KB Output is correct
29 Correct 4 ms 972 KB Output is correct
30 Correct 2 ms 588 KB Output is correct
31 Correct 19 ms 3896 KB Output is correct
32 Correct 12 ms 3020 KB Output is correct
33 Correct 12 ms 3020 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 460 KB Output is correct
37 Correct 8 ms 1608 KB Output is correct
38 Correct 2 ms 588 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 7 ms 1996 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 2 ms 588 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 6 ms 1356 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 2 ms 460 KB Output is correct
50 Correct 140 ms 29884 KB Output is correct
51 Correct 113 ms 24260 KB Output is correct
52 Correct 112 ms 22960 KB Output is correct
53 Correct 96 ms 18796 KB Output is correct
54 Correct 48 ms 10436 KB Output is correct
55 Correct 183 ms 37652 KB Output is correct
56 Correct 146 ms 31020 KB Output is correct
57 Correct 149 ms 31696 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 2 ms 716 KB Output is correct
61 Correct 38 ms 8516 KB Output is correct
62 Correct 21 ms 5268 KB Output is correct
63 Correct 9 ms 1852 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 50 ms 10816 KB Output is correct
66 Correct 1 ms 204 KB Output is correct
67 Correct 0 ms 204 KB Output is correct
68 Correct 1 ms 332 KB Output is correct
69 Correct 3 ms 972 KB Output is correct
70 Correct 31 ms 7296 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 1 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 0 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 1 ms 204 KB Output is correct
26 Correct 15 ms 3540 KB Output is correct
27 Correct 11 ms 2928 KB Output is correct
28 Correct 6 ms 1356 KB Output is correct
29 Correct 4 ms 972 KB Output is correct
30 Correct 2 ms 588 KB Output is correct
31 Correct 19 ms 3896 KB Output is correct
32 Correct 12 ms 3020 KB Output is correct
33 Correct 12 ms 3020 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 460 KB Output is correct
37 Correct 8 ms 1608 KB Output is correct
38 Correct 2 ms 588 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 7 ms 1996 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 2 ms 588 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 6 ms 1356 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 2 ms 460 KB Output is correct
50 Correct 140 ms 29884 KB Output is correct
51 Correct 113 ms 24260 KB Output is correct
52 Correct 112 ms 22960 KB Output is correct
53 Correct 96 ms 18796 KB Output is correct
54 Correct 48 ms 10436 KB Output is correct
55 Correct 183 ms 37652 KB Output is correct
56 Correct 146 ms 31020 KB Output is correct
57 Correct 149 ms 31696 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 2 ms 716 KB Output is correct
61 Correct 38 ms 8516 KB Output is correct
62 Correct 21 ms 5268 KB Output is correct
63 Correct 9 ms 1852 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 50 ms 10816 KB Output is correct
66 Correct 1 ms 204 KB Output is correct
67 Correct 0 ms 204 KB Output is correct
68 Correct 1 ms 332 KB Output is correct
69 Correct 3 ms 972 KB Output is correct
70 Correct 31 ms 7296 KB Output is correct
71 Runtime error 1006 ms 262148 KB Execution killed with signal 9
72 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 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 1 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 0 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 1 ms 204 KB Output is correct
26 Correct 15 ms 3540 KB Output is correct
27 Correct 11 ms 2928 KB Output is correct
28 Correct 6 ms 1356 KB Output is correct
29 Correct 4 ms 972 KB Output is correct
30 Correct 2 ms 588 KB Output is correct
31 Correct 19 ms 3896 KB Output is correct
32 Correct 12 ms 3020 KB Output is correct
33 Correct 12 ms 3020 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 460 KB Output is correct
37 Correct 8 ms 1608 KB Output is correct
38 Correct 2 ms 588 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 7 ms 1996 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 2 ms 588 KB Output is correct
46 Correct 0 ms 204 KB Output is correct
47 Correct 6 ms 1356 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 2 ms 460 KB Output is correct
50 Correct 140 ms 29884 KB Output is correct
51 Correct 113 ms 24260 KB Output is correct
52 Correct 112 ms 22960 KB Output is correct
53 Correct 96 ms 18796 KB Output is correct
54 Correct 48 ms 10436 KB Output is correct
55 Correct 183 ms 37652 KB Output is correct
56 Correct 146 ms 31020 KB Output is correct
57 Correct 149 ms 31696 KB Output is correct
58 Correct 0 ms 204 KB Output is correct
59 Correct 0 ms 204 KB Output is correct
60 Correct 2 ms 716 KB Output is correct
61 Correct 38 ms 8516 KB Output is correct
62 Correct 21 ms 5268 KB Output is correct
63 Correct 9 ms 1852 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 50 ms 10816 KB Output is correct
66 Correct 1 ms 204 KB Output is correct
67 Correct 0 ms 204 KB Output is correct
68 Correct 1 ms 332 KB Output is correct
69 Correct 3 ms 972 KB Output is correct
70 Correct 31 ms 7296 KB Output is correct
71 Runtime error 1006 ms 262148 KB Execution killed with signal 9
72 Halted 0 ms 0 KB -