Submission #548751

# Submission time Handle Problem Language Result Execution time Memory
548751 2022-04-14T11:25:22 Z Vladth11 Toys (CEOI18_toy) C++14
59 / 100
1151 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(divisors[k] == 0) 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()){
      |        ~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 240 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 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 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 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 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 240 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 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 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 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 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 19 ms 4008 KB Output is correct
27 Correct 15 ms 3240 KB Output is correct
28 Correct 7 ms 1620 KB Output is correct
29 Correct 6 ms 1108 KB Output is correct
30 Correct 4 ms 724 KB Output is correct
31 Correct 20 ms 4184 KB Output is correct
32 Correct 20 ms 3376 KB Output is correct
33 Correct 21 ms 3404 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 0 ms 212 KB Output is correct
40 Correct 10 ms 2184 KB Output is correct
41 Correct 1 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 3 ms 724 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 9 ms 1620 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 2 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 240 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 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 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 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 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 19 ms 4008 KB Output is correct
27 Correct 15 ms 3240 KB Output is correct
28 Correct 7 ms 1620 KB Output is correct
29 Correct 6 ms 1108 KB Output is correct
30 Correct 4 ms 724 KB Output is correct
31 Correct 20 ms 4184 KB Output is correct
32 Correct 20 ms 3376 KB Output is correct
33 Correct 21 ms 3404 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 0 ms 212 KB Output is correct
40 Correct 10 ms 2184 KB Output is correct
41 Correct 1 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 3 ms 724 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 9 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 203 ms 32472 KB Output is correct
51 Correct 157 ms 26416 KB Output is correct
52 Correct 163 ms 24700 KB Output is correct
53 Correct 140 ms 20364 KB Output is correct
54 Correct 66 ms 11576 KB Output is correct
55 Correct 269 ms 40476 KB Output is correct
56 Correct 237 ms 33340 KB Output is correct
57 Correct 222 ms 34316 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 916 KB Output is correct
61 Correct 49 ms 9648 KB Output is correct
62 Correct 29 ms 5900 KB Output is correct
63 Correct 10 ms 2188 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 79 ms 12008 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 0 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 42 ms 8236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 240 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 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 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 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 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 19 ms 4008 KB Output is correct
27 Correct 15 ms 3240 KB Output is correct
28 Correct 7 ms 1620 KB Output is correct
29 Correct 6 ms 1108 KB Output is correct
30 Correct 4 ms 724 KB Output is correct
31 Correct 20 ms 4184 KB Output is correct
32 Correct 20 ms 3376 KB Output is correct
33 Correct 21 ms 3404 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 0 ms 212 KB Output is correct
40 Correct 10 ms 2184 KB Output is correct
41 Correct 1 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 3 ms 724 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 9 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 203 ms 32472 KB Output is correct
51 Correct 157 ms 26416 KB Output is correct
52 Correct 163 ms 24700 KB Output is correct
53 Correct 140 ms 20364 KB Output is correct
54 Correct 66 ms 11576 KB Output is correct
55 Correct 269 ms 40476 KB Output is correct
56 Correct 237 ms 33340 KB Output is correct
57 Correct 222 ms 34316 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 916 KB Output is correct
61 Correct 49 ms 9648 KB Output is correct
62 Correct 29 ms 5900 KB Output is correct
63 Correct 10 ms 2188 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 79 ms 12008 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 0 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 42 ms 8236 KB Output is correct
71 Runtime error 1151 ms 262144 KB Execution killed with signal 9
72 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 240 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 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 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 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 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 19 ms 4008 KB Output is correct
27 Correct 15 ms 3240 KB Output is correct
28 Correct 7 ms 1620 KB Output is correct
29 Correct 6 ms 1108 KB Output is correct
30 Correct 4 ms 724 KB Output is correct
31 Correct 20 ms 4184 KB Output is correct
32 Correct 20 ms 3376 KB Output is correct
33 Correct 21 ms 3404 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 0 ms 212 KB Output is correct
40 Correct 10 ms 2184 KB Output is correct
41 Correct 1 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 3 ms 724 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 9 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 203 ms 32472 KB Output is correct
51 Correct 157 ms 26416 KB Output is correct
52 Correct 163 ms 24700 KB Output is correct
53 Correct 140 ms 20364 KB Output is correct
54 Correct 66 ms 11576 KB Output is correct
55 Correct 269 ms 40476 KB Output is correct
56 Correct 237 ms 33340 KB Output is correct
57 Correct 222 ms 34316 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 916 KB Output is correct
61 Correct 49 ms 9648 KB Output is correct
62 Correct 29 ms 5900 KB Output is correct
63 Correct 10 ms 2188 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 79 ms 12008 KB Output is correct
66 Correct 1 ms 212 KB Output is correct
67 Correct 0 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 42 ms 8236 KB Output is correct
71 Runtime error 1151 ms 262144 KB Execution killed with signal 9
72 Halted 0 ms 0 KB -