답안 #548746

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
548746 2022-04-14T11:22:41 Z Vladth11 Toys (CEOI18_toy) C++14
59 / 100
1040 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 <int, int>, int > > mp;

set <int> sol;
vector <int> divisors;

void bkt(int k, int n, int 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);
    int 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(int, int, int)':
toy.cpp:31:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     if(k == divisors.size()){
      |        ~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 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 320 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 316 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 320 KB Output is correct
14 Correct 0 ms 324 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 472 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 0 ms 324 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 320 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 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 320 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 316 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 320 KB Output is correct
14 Correct 0 ms 324 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 472 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 0 ms 324 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 320 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 17 ms 4012 KB Output is correct
27 Correct 13 ms 3272 KB Output is correct
28 Correct 5 ms 1620 KB Output is correct
29 Correct 4 ms 1092 KB Output is correct
30 Correct 2 ms 724 KB Output is correct
31 Correct 18 ms 4224 KB Output is correct
32 Correct 13 ms 3408 KB Output is correct
33 Correct 13 ms 3352 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 708 KB Output is correct
39 Correct 0 ms 328 KB Output is correct
40 Correct 10 ms 2244 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 0 ms 212 KB Output is correct
45 Correct 3 ms 724 KB Output is correct
46 Correct 1 ms 320 KB Output is correct
47 Correct 7 ms 1620 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 2 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 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 320 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 316 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 320 KB Output is correct
14 Correct 0 ms 324 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 472 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 0 ms 324 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 320 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 17 ms 4012 KB Output is correct
27 Correct 13 ms 3272 KB Output is correct
28 Correct 5 ms 1620 KB Output is correct
29 Correct 4 ms 1092 KB Output is correct
30 Correct 2 ms 724 KB Output is correct
31 Correct 18 ms 4224 KB Output is correct
32 Correct 13 ms 3408 KB Output is correct
33 Correct 13 ms 3352 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 708 KB Output is correct
39 Correct 0 ms 328 KB Output is correct
40 Correct 10 ms 2244 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 0 ms 212 KB Output is correct
45 Correct 3 ms 724 KB Output is correct
46 Correct 1 ms 320 KB Output is correct
47 Correct 7 ms 1620 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 2 ms 596 KB Output is correct
50 Correct 176 ms 32576 KB Output is correct
51 Correct 141 ms 26388 KB Output is correct
52 Correct 131 ms 24696 KB Output is correct
53 Correct 110 ms 20488 KB Output is correct
54 Correct 52 ms 11456 KB Output is correct
55 Correct 218 ms 40484 KB Output is correct
56 Correct 181 ms 33312 KB Output is correct
57 Correct 216 ms 34380 KB Output is correct
58 Correct 0 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 46 ms 9624 KB Output is correct
62 Correct 25 ms 5972 KB Output is correct
63 Correct 8 ms 2092 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 61 ms 12084 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 4 ms 1236 KB Output is correct
70 Correct 39 ms 8252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 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 320 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 316 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 320 KB Output is correct
14 Correct 0 ms 324 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 472 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 0 ms 324 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 320 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 17 ms 4012 KB Output is correct
27 Correct 13 ms 3272 KB Output is correct
28 Correct 5 ms 1620 KB Output is correct
29 Correct 4 ms 1092 KB Output is correct
30 Correct 2 ms 724 KB Output is correct
31 Correct 18 ms 4224 KB Output is correct
32 Correct 13 ms 3408 KB Output is correct
33 Correct 13 ms 3352 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 708 KB Output is correct
39 Correct 0 ms 328 KB Output is correct
40 Correct 10 ms 2244 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 0 ms 212 KB Output is correct
45 Correct 3 ms 724 KB Output is correct
46 Correct 1 ms 320 KB Output is correct
47 Correct 7 ms 1620 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 2 ms 596 KB Output is correct
50 Correct 176 ms 32576 KB Output is correct
51 Correct 141 ms 26388 KB Output is correct
52 Correct 131 ms 24696 KB Output is correct
53 Correct 110 ms 20488 KB Output is correct
54 Correct 52 ms 11456 KB Output is correct
55 Correct 218 ms 40484 KB Output is correct
56 Correct 181 ms 33312 KB Output is correct
57 Correct 216 ms 34380 KB Output is correct
58 Correct 0 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 46 ms 9624 KB Output is correct
62 Correct 25 ms 5972 KB Output is correct
63 Correct 8 ms 2092 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 61 ms 12084 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 4 ms 1236 KB Output is correct
70 Correct 39 ms 8252 KB Output is correct
71 Runtime error 1040 ms 262144 KB Execution killed with signal 9
72 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 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 320 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 316 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 320 KB Output is correct
14 Correct 0 ms 324 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 472 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 320 KB Output is correct
21 Correct 0 ms 324 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 320 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 17 ms 4012 KB Output is correct
27 Correct 13 ms 3272 KB Output is correct
28 Correct 5 ms 1620 KB Output is correct
29 Correct 4 ms 1092 KB Output is correct
30 Correct 2 ms 724 KB Output is correct
31 Correct 18 ms 4224 KB Output is correct
32 Correct 13 ms 3408 KB Output is correct
33 Correct 13 ms 3352 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 708 KB Output is correct
39 Correct 0 ms 328 KB Output is correct
40 Correct 10 ms 2244 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 0 ms 212 KB Output is correct
45 Correct 3 ms 724 KB Output is correct
46 Correct 1 ms 320 KB Output is correct
47 Correct 7 ms 1620 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 2 ms 596 KB Output is correct
50 Correct 176 ms 32576 KB Output is correct
51 Correct 141 ms 26388 KB Output is correct
52 Correct 131 ms 24696 KB Output is correct
53 Correct 110 ms 20488 KB Output is correct
54 Correct 52 ms 11456 KB Output is correct
55 Correct 218 ms 40484 KB Output is correct
56 Correct 181 ms 33312 KB Output is correct
57 Correct 216 ms 34380 KB Output is correct
58 Correct 0 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 46 ms 9624 KB Output is correct
62 Correct 25 ms 5972 KB Output is correct
63 Correct 8 ms 2092 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 61 ms 12084 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 4 ms 1236 KB Output is correct
70 Correct 39 ms 8252 KB Output is correct
71 Runtime error 1040 ms 262144 KB Execution killed with signal 9
72 Halted 0 ms 0 KB -