Submission #1039144

# Submission time Handle Problem Language Result Execution time Memory
1039144 2024-07-30T13:40:27 Z 0npata Toys (CEOI18_toy) C++17
100 / 100
2266 ms 33364 KB
#include<bits/stdc++.h>
using namespace std;
 
#define vec vector
#define int long long
 
 
vec<int> ans;
vec<pair<int, int>> primes(0);
 
int n;
 
 
void find_primes() {
    int cn = n;
    for(int i = 2; i*i <= cn; i++) {
       if(cn % i == 0) {
           primes.push_back({i, 0});
           while(cn % i == 0) {
               cn /= i;
               primes.back().second++;
           }
       }
    }
    if(cn != 1) primes.push_back({cn, 1});
}
 
 
void go(int cur, int lst, int id, int pi=0, int mul= 1) {
    bool done = true;
    if(mul == n) {
        ans.push_back(id); 
        return;
    }

    if(pi == primes.size()) return;

    int j = pi;
    go(cur, lst, id, pi+1, mul);
    auto &[p, cnt] = primes[j];
    int val = 1;
    for(int i = 0; i<cnt; i++) {
        val *= p;
        cnt -= (i+1); 
        if(cur * val >= lst) {
            go(1, cur*val, id + cur*val-1, 0, mul*cur*val);
        }
        go(cur*val, lst, id, pi+1, mul);
        cnt += (i+1);
   }
}
 
int32_t main() {
    cin >> n;
    
    find_primes();
     
     go(1, 0, 0);
 
     vec<int> ans_filt(0);
     sort(ans.begin(), ans.end());
     ans_filt.push_back(ans[0]);
     for(int i = 1; i<ans.size(); i++) {
         if(ans[i] != ans[i-1]) {
             ans_filt.push_back(ans[i]);
         }
     }
 
    cout << ans_filt.size() << '\n';
    for(int res : ans_filt) {
        cout << res << ' ';
    }
    cout << '\n';
}

Compilation message

toy.cpp: In function 'void go(long long int, long long int, long long int, long long int, long long int)':
toy.cpp:36:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     if(pi == primes.size()) return;
      |        ~~~^~~~~~~~~~~~~~~~
toy.cpp:30:10: warning: unused variable 'done' [-Wunused-variable]
   30 |     bool done = true;
      |          ^~~~
toy.cpp: In function 'int32_t main()':
toy.cpp:63:22: 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]
   63 |      for(int i = 1; i<ans.size(); i++) {
      |                     ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 356 KB Output is correct
42 Correct 0 ms 352 KB Output is correct
43 Correct 0 ms 352 KB Output is correct
44 Correct 0 ms 352 KB Output is correct
45 Correct 0 ms 352 KB Output is correct
46 Correct 0 ms 352 KB Output is correct
47 Correct 0 ms 352 KB Output is correct
48 Correct 0 ms 352 KB Output is correct
49 Correct 0 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 356 KB Output is correct
42 Correct 0 ms 352 KB Output is correct
43 Correct 0 ms 352 KB Output is correct
44 Correct 0 ms 352 KB Output is correct
45 Correct 0 ms 352 KB Output is correct
46 Correct 0 ms 352 KB Output is correct
47 Correct 0 ms 352 KB Output is correct
48 Correct 0 ms 352 KB Output is correct
49 Correct 0 ms 352 KB Output is correct
50 Correct 1 ms 344 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 1 ms 352 KB Output is correct
53 Correct 1 ms 352 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 2 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 1 ms 344 KB Output is correct
64 Correct 0 ms 348 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 1 ms 348 KB Output is correct
67 Correct 0 ms 348 KB Output is correct
68 Correct 1 ms 348 KB Output is correct
69 Correct 0 ms 344 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 356 KB Output is correct
42 Correct 0 ms 352 KB Output is correct
43 Correct 0 ms 352 KB Output is correct
44 Correct 0 ms 352 KB Output is correct
45 Correct 0 ms 352 KB Output is correct
46 Correct 0 ms 352 KB Output is correct
47 Correct 0 ms 352 KB Output is correct
48 Correct 0 ms 352 KB Output is correct
49 Correct 0 ms 352 KB Output is correct
50 Correct 1 ms 344 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 1 ms 352 KB Output is correct
53 Correct 1 ms 352 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 2 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 1 ms 344 KB Output is correct
64 Correct 0 ms 348 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 1 ms 348 KB Output is correct
67 Correct 0 ms 348 KB Output is correct
68 Correct 1 ms 348 KB Output is correct
69 Correct 0 ms 344 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
71 Correct 171 ms 6656 KB Output is correct
72 Correct 94 ms 2608 KB Output is correct
73 Correct 188 ms 6608 KB Output is correct
74 Correct 79 ms 1732 KB Output is correct
75 Correct 103 ms 2500 KB Output is correct
76 Correct 368 ms 8516 KB Output is correct
77 Correct 369 ms 8632 KB Output is correct
78 Correct 289 ms 5528 KB Output is correct
79 Correct 307 ms 5128 KB Output is correct
80 Correct 0 ms 344 KB Output is correct
81 Correct 0 ms 344 KB Output is correct
82 Correct 1 ms 348 KB Output is correct
83 Correct 15 ms 984 KB Output is correct
84 Correct 18 ms 1064 KB Output is correct
85 Correct 3 ms 604 KB Output is correct
86 Correct 0 ms 344 KB Output is correct
87 Correct 16 ms 984 KB Output is correct
88 Correct 0 ms 348 KB Output is correct
89 Correct 0 ms 348 KB Output is correct
90 Correct 0 ms 348 KB Output is correct
91 Correct 4 ms 604 KB Output is correct
92 Correct 24 ms 1068 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 356 KB Output is correct
42 Correct 0 ms 352 KB Output is correct
43 Correct 0 ms 352 KB Output is correct
44 Correct 0 ms 352 KB Output is correct
45 Correct 0 ms 352 KB Output is correct
46 Correct 0 ms 352 KB Output is correct
47 Correct 0 ms 352 KB Output is correct
48 Correct 0 ms 352 KB Output is correct
49 Correct 0 ms 352 KB Output is correct
50 Correct 1 ms 344 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 1 ms 352 KB Output is correct
53 Correct 1 ms 352 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 2 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 1 ms 344 KB Output is correct
64 Correct 0 ms 348 KB Output is correct
65 Correct 0 ms 348 KB Output is correct
66 Correct 1 ms 348 KB Output is correct
67 Correct 0 ms 348 KB Output is correct
68 Correct 1 ms 348 KB Output is correct
69 Correct 0 ms 344 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
71 Correct 171 ms 6656 KB Output is correct
72 Correct 94 ms 2608 KB Output is correct
73 Correct 188 ms 6608 KB Output is correct
74 Correct 79 ms 1732 KB Output is correct
75 Correct 103 ms 2500 KB Output is correct
76 Correct 368 ms 8516 KB Output is correct
77 Correct 369 ms 8632 KB Output is correct
78 Correct 289 ms 5528 KB Output is correct
79 Correct 307 ms 5128 KB Output is correct
80 Correct 0 ms 344 KB Output is correct
81 Correct 0 ms 344 KB Output is correct
82 Correct 1 ms 348 KB Output is correct
83 Correct 15 ms 984 KB Output is correct
84 Correct 18 ms 1064 KB Output is correct
85 Correct 3 ms 604 KB Output is correct
86 Correct 0 ms 344 KB Output is correct
87 Correct 16 ms 984 KB Output is correct
88 Correct 0 ms 348 KB Output is correct
89 Correct 0 ms 348 KB Output is correct
90 Correct 0 ms 348 KB Output is correct
91 Correct 4 ms 604 KB Output is correct
92 Correct 24 ms 1068 KB Output is correct
93 Correct 1396 ms 18332 KB Output is correct
94 Correct 506 ms 8740 KB Output is correct
95 Correct 748 ms 16972 KB Output is correct
96 Correct 661 ms 9408 KB Output is correct
97 Correct 614 ms 9388 KB Output is correct
98 Correct 1716 ms 33180 KB Output is correct
99 Correct 1933 ms 33212 KB Output is correct
100 Correct 1778 ms 33180 KB Output is correct
101 Correct 2266 ms 33180 KB Output is correct
102 Correct 1850 ms 33364 KB Output is correct
103 Correct 892 ms 16736 KB Output is correct
104 Correct 0 ms 348 KB Output is correct
105 Correct 0 ms 348 KB Output is correct
106 Correct 1 ms 348 KB Output is correct
107 Correct 72 ms 2768 KB Output is correct
108 Correct 170 ms 6080 KB Output is correct
109 Correct 6 ms 724 KB Output is correct
110 Correct 1 ms 348 KB Output is correct
111 Correct 55 ms 2524 KB Output is correct
112 Correct 0 ms 348 KB Output is correct
113 Correct 0 ms 348 KB Output is correct
114 Correct 1 ms 348 KB Output is correct
115 Correct 0 ms 348 KB Output is correct
116 Correct 3 ms 604 KB Output is correct
117 Correct 127 ms 2692 KB Output is correct