답안 #548748

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
548748 2022-04-14T11:24:15 Z Vladth11 Toys (CEOI18_toy) C++14
59 / 100
1050 ms 262144 KB
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "

using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef pair <pair <ll, ll>, ll > ura;

const ll NMAX = 1000001;
const ll VMAX = 26;
const ll INF = (1LL << 55);
const ll MOD = 90000000000000001;
const ll BLOCK = 1000000;
const ll base = 1000000001;
const ll nr_of_bits = 18;

set <pair <pair <ll, ll>, ll > > mp;

set <ll> sol;
vector <ll> divisors;

void bkt(ll k, ll n, ll sum){
    if(mp.find({{k, n}, sum}) != mp.end()){
        return;
    }
    mp.insert({{k, n}, sum});
    if(n == 1){
        sol.insert(sum);
    }
    if(k == divisors.size()){
        return;
    }
    if(n % divisors[k] == 0){
        bkt(k, n / divisors[k], sum + divisors[k] - 1);
    }
    bkt(k + 1, n, sum);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, i;
    cin >> n;
    for(i = 1; i * i <= n; i++){
        if(n % i == 0){
            if(n / i == i){
                divisors.push_back(i);
            }else{
                divisors.push_back(i);
                divisors.push_back(n / i);
            }
        }
    }
    sort(divisors.begin(), divisors.end());
    bkt(0, n, 0);
    cout << sol.size() << "\n";
    for(auto x : sol){
        cout << x << " ";
    }
    return 0;
}

Compilation message

toy.cpp: In function 'void bkt(ll, ll, ll)':
toy.cpp:31:10: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     if(k == divisors.size()){
      |        ~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 320 KB Output is correct
26 Correct 23 ms 4024 KB Output is correct
27 Correct 15 ms 3260 KB Output is correct
28 Correct 7 ms 1632 KB Output is correct
29 Correct 5 ms 1108 KB Output is correct
30 Correct 3 ms 724 KB Output is correct
31 Correct 18 ms 4180 KB Output is correct
32 Correct 13 ms 3412 KB Output is correct
33 Correct 14 ms 3408 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 7 ms 1748 KB Output is correct
38 Correct 2 ms 596 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 9 ms 2268 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 2 ms 724 KB Output is correct
46 Correct 1 ms 324 KB Output is correct
47 Correct 6 ms 1620 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 2 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 320 KB Output is correct
26 Correct 23 ms 4024 KB Output is correct
27 Correct 15 ms 3260 KB Output is correct
28 Correct 7 ms 1632 KB Output is correct
29 Correct 5 ms 1108 KB Output is correct
30 Correct 3 ms 724 KB Output is correct
31 Correct 18 ms 4180 KB Output is correct
32 Correct 13 ms 3412 KB Output is correct
33 Correct 14 ms 3408 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 7 ms 1748 KB Output is correct
38 Correct 2 ms 596 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 9 ms 2268 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 2 ms 724 KB Output is correct
46 Correct 1 ms 324 KB Output is correct
47 Correct 6 ms 1620 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 2 ms 596 KB Output is correct
50 Correct 197 ms 32408 KB Output is correct
51 Correct 142 ms 26336 KB Output is correct
52 Correct 139 ms 24744 KB Output is correct
53 Correct 117 ms 20372 KB Output is correct
54 Correct 56 ms 11568 KB Output is correct
55 Correct 228 ms 40524 KB Output is correct
56 Correct 179 ms 33408 KB Output is correct
57 Correct 212 ms 34236 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 3 ms 852 KB Output is correct
61 Correct 50 ms 9696 KB Output is correct
62 Correct 25 ms 5912 KB Output is correct
63 Correct 9 ms 2132 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 72 ms 12056 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 340 KB Output is correct
69 Correct 5 ms 1108 KB Output is correct
70 Correct 40 ms 8204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 320 KB Output is correct
26 Correct 23 ms 4024 KB Output is correct
27 Correct 15 ms 3260 KB Output is correct
28 Correct 7 ms 1632 KB Output is correct
29 Correct 5 ms 1108 KB Output is correct
30 Correct 3 ms 724 KB Output is correct
31 Correct 18 ms 4180 KB Output is correct
32 Correct 13 ms 3412 KB Output is correct
33 Correct 14 ms 3408 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 7 ms 1748 KB Output is correct
38 Correct 2 ms 596 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 9 ms 2268 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 2 ms 724 KB Output is correct
46 Correct 1 ms 324 KB Output is correct
47 Correct 6 ms 1620 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 2 ms 596 KB Output is correct
50 Correct 197 ms 32408 KB Output is correct
51 Correct 142 ms 26336 KB Output is correct
52 Correct 139 ms 24744 KB Output is correct
53 Correct 117 ms 20372 KB Output is correct
54 Correct 56 ms 11568 KB Output is correct
55 Correct 228 ms 40524 KB Output is correct
56 Correct 179 ms 33408 KB Output is correct
57 Correct 212 ms 34236 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 3 ms 852 KB Output is correct
61 Correct 50 ms 9696 KB Output is correct
62 Correct 25 ms 5912 KB Output is correct
63 Correct 9 ms 2132 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 72 ms 12056 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 340 KB Output is correct
69 Correct 5 ms 1108 KB Output is correct
70 Correct 40 ms 8204 KB Output is correct
71 Runtime error 1050 ms 262144 KB Execution killed with signal 9
72 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 316 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 320 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 320 KB Output is correct
26 Correct 23 ms 4024 KB Output is correct
27 Correct 15 ms 3260 KB Output is correct
28 Correct 7 ms 1632 KB Output is correct
29 Correct 5 ms 1108 KB Output is correct
30 Correct 3 ms 724 KB Output is correct
31 Correct 18 ms 4180 KB Output is correct
32 Correct 13 ms 3412 KB Output is correct
33 Correct 14 ms 3408 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 468 KB Output is correct
37 Correct 7 ms 1748 KB Output is correct
38 Correct 2 ms 596 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 9 ms 2268 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 2 ms 724 KB Output is correct
46 Correct 1 ms 324 KB Output is correct
47 Correct 6 ms 1620 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 2 ms 596 KB Output is correct
50 Correct 197 ms 32408 KB Output is correct
51 Correct 142 ms 26336 KB Output is correct
52 Correct 139 ms 24744 KB Output is correct
53 Correct 117 ms 20372 KB Output is correct
54 Correct 56 ms 11568 KB Output is correct
55 Correct 228 ms 40524 KB Output is correct
56 Correct 179 ms 33408 KB Output is correct
57 Correct 212 ms 34236 KB Output is correct
58 Correct 1 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 3 ms 852 KB Output is correct
61 Correct 50 ms 9696 KB Output is correct
62 Correct 25 ms 5912 KB Output is correct
63 Correct 9 ms 2132 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 72 ms 12056 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 340 KB Output is correct
69 Correct 5 ms 1108 KB Output is correct
70 Correct 40 ms 8204 KB Output is correct
71 Runtime error 1050 ms 262144 KB Execution killed with signal 9
72 Halted 0 ms 0 KB -