Submission #417352

# Submission time Handle Problem Language Result Execution time Memory
417352 2021-06-03T15:12:26 Z egekabas Toys (CEOI18_toy) C++14
100 / 100
1302 ms 136868 KB
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
int n;
vector<pii> vec;
vector<int> val[1000009];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);

    cin >> n;

    map<int, int> mpp;    
    for(int i = 2; i*i <= n; ++i)
        while(n%i == 0){
            n /= i;
            mpp[i]++;
        }
    if(n > 1) mpp[n]++;
    for(auto u : mpp){
        vec.pb(u);
        //cout << u.ff << ' ' << u.ss << '\n';
    }
    val[0] = {0};
    vector<int> cur(vec.size(), 0);
    int n = cur.size();
    int curcnt = 0;
    while(1){
        ++curcnt;
        int add = 1;

        for(int i = 0; i < n && add; ++i){
            cur[i]++;
            add = 0;
            if(cur[i] > vec[i].ss){
                cur[i] = 0;
                ++add;
            }
        }
        if(add) break;
        vector<int> nxt(n);
        while(1){
            int add = 1;
            for(int i = 0; i < n && add; ++i){
                nxt[i]++;
                add = 0;
                if(nxt[i] > cur[i]){
                    nxt[i] = 0;
                    ++add;
                }
            }
            if(add) break;
        
            int cursum = 1;
            int nxtval = curcnt;
            int totbef = 1;

            //for(int i = 0; i < n; ++i)
            //    cout << vec[i].ff << ' ' << nxt[i] << '\n';
            for(int i = 0; i < n; ++i){
                nxtval -= totbef*nxt[i];
                for(int j = 0; j < nxt[i]; ++j){
                    cursum *= vec[i].ff;
                    //cout << vec[i].ff << '\n';
                }
                totbef *= (vec[i].ss+1);
            }
            //cout << cursum-1 << "\n\n";
            //cout << nxtval << '\n';
            for(auto u : val[nxtval])
                val[curcnt].pb(u+cursum-1);
        }
        sort(all(val[curcnt]));
        val[curcnt].resize(unique(all(val[curcnt]))-val[curcnt].begin());
        //for(int i = 0; i < n; ++i)
        //    cout << vec[i].ff << ' ' << cur[i] << '\n';
        //cout << curcnt << '\n';
        //cout << val[curcnt][0] << "\n\n";
        
    }
    int idx = 0;
    int totbef = 1;
    for(auto u : vec){
        idx += u.ss*totbef;
        totbef *= u.ss+1;
    }
    cout << val[idx].size() << '\n';
    for(auto u : val[idx])
        cout << u << ' ';
}
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23756 KB Output is correct
2 Correct 14 ms 23736 KB Output is correct
3 Correct 14 ms 23796 KB Output is correct
4 Correct 14 ms 23800 KB Output is correct
5 Correct 15 ms 23804 KB Output is correct
6 Correct 14 ms 23756 KB Output is correct
7 Correct 14 ms 23756 KB Output is correct
8 Correct 13 ms 23756 KB Output is correct
9 Correct 14 ms 23796 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
11 Correct 14 ms 23796 KB Output is correct
12 Correct 14 ms 23804 KB Output is correct
13 Correct 14 ms 23760 KB Output is correct
14 Correct 15 ms 23756 KB Output is correct
15 Correct 14 ms 23756 KB Output is correct
16 Correct 14 ms 23756 KB Output is correct
17 Correct 15 ms 23784 KB Output is correct
18 Correct 14 ms 23800 KB Output is correct
19 Correct 15 ms 23756 KB Output is correct
20 Correct 14 ms 23796 KB Output is correct
21 Correct 14 ms 23692 KB Output is correct
22 Correct 14 ms 23756 KB Output is correct
23 Correct 14 ms 23756 KB Output is correct
24 Correct 14 ms 23692 KB Output is correct
25 Correct 13 ms 23756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23756 KB Output is correct
2 Correct 14 ms 23736 KB Output is correct
3 Correct 14 ms 23796 KB Output is correct
4 Correct 14 ms 23800 KB Output is correct
5 Correct 15 ms 23804 KB Output is correct
6 Correct 14 ms 23756 KB Output is correct
7 Correct 14 ms 23756 KB Output is correct
8 Correct 13 ms 23756 KB Output is correct
9 Correct 14 ms 23796 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
11 Correct 14 ms 23796 KB Output is correct
12 Correct 14 ms 23804 KB Output is correct
13 Correct 14 ms 23760 KB Output is correct
14 Correct 15 ms 23756 KB Output is correct
15 Correct 14 ms 23756 KB Output is correct
16 Correct 14 ms 23756 KB Output is correct
17 Correct 15 ms 23784 KB Output is correct
18 Correct 14 ms 23800 KB Output is correct
19 Correct 15 ms 23756 KB Output is correct
20 Correct 14 ms 23796 KB Output is correct
21 Correct 14 ms 23692 KB Output is correct
22 Correct 14 ms 23756 KB Output is correct
23 Correct 14 ms 23756 KB Output is correct
24 Correct 14 ms 23692 KB Output is correct
25 Correct 13 ms 23756 KB Output is correct
26 Correct 16 ms 23800 KB Output is correct
27 Correct 14 ms 23744 KB Output is correct
28 Correct 15 ms 23884 KB Output is correct
29 Correct 15 ms 23800 KB Output is correct
30 Correct 14 ms 23764 KB Output is correct
31 Correct 15 ms 23760 KB Output is correct
32 Correct 16 ms 23756 KB Output is correct
33 Correct 16 ms 23836 KB Output is correct
34 Correct 14 ms 23796 KB Output is correct
35 Correct 14 ms 23728 KB Output is correct
36 Correct 15 ms 23800 KB Output is correct
37 Correct 14 ms 23716 KB Output is correct
38 Correct 14 ms 23756 KB Output is correct
39 Correct 14 ms 23776 KB Output is correct
40 Correct 14 ms 23756 KB Output is correct
41 Correct 14 ms 23752 KB Output is correct
42 Correct 14 ms 23800 KB Output is correct
43 Correct 17 ms 23800 KB Output is correct
44 Correct 14 ms 23800 KB Output is correct
45 Correct 14 ms 23800 KB Output is correct
46 Correct 16 ms 23820 KB Output is correct
47 Correct 16 ms 23800 KB Output is correct
48 Correct 13 ms 23756 KB Output is correct
49 Correct 14 ms 23808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23756 KB Output is correct
2 Correct 14 ms 23736 KB Output is correct
3 Correct 14 ms 23796 KB Output is correct
4 Correct 14 ms 23800 KB Output is correct
5 Correct 15 ms 23804 KB Output is correct
6 Correct 14 ms 23756 KB Output is correct
7 Correct 14 ms 23756 KB Output is correct
8 Correct 13 ms 23756 KB Output is correct
9 Correct 14 ms 23796 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
11 Correct 14 ms 23796 KB Output is correct
12 Correct 14 ms 23804 KB Output is correct
13 Correct 14 ms 23760 KB Output is correct
14 Correct 15 ms 23756 KB Output is correct
15 Correct 14 ms 23756 KB Output is correct
16 Correct 14 ms 23756 KB Output is correct
17 Correct 15 ms 23784 KB Output is correct
18 Correct 14 ms 23800 KB Output is correct
19 Correct 15 ms 23756 KB Output is correct
20 Correct 14 ms 23796 KB Output is correct
21 Correct 14 ms 23692 KB Output is correct
22 Correct 14 ms 23756 KB Output is correct
23 Correct 14 ms 23756 KB Output is correct
24 Correct 14 ms 23692 KB Output is correct
25 Correct 13 ms 23756 KB Output is correct
26 Correct 16 ms 23800 KB Output is correct
27 Correct 14 ms 23744 KB Output is correct
28 Correct 15 ms 23884 KB Output is correct
29 Correct 15 ms 23800 KB Output is correct
30 Correct 14 ms 23764 KB Output is correct
31 Correct 15 ms 23760 KB Output is correct
32 Correct 16 ms 23756 KB Output is correct
33 Correct 16 ms 23836 KB Output is correct
34 Correct 14 ms 23796 KB Output is correct
35 Correct 14 ms 23728 KB Output is correct
36 Correct 15 ms 23800 KB Output is correct
37 Correct 14 ms 23716 KB Output is correct
38 Correct 14 ms 23756 KB Output is correct
39 Correct 14 ms 23776 KB Output is correct
40 Correct 14 ms 23756 KB Output is correct
41 Correct 14 ms 23752 KB Output is correct
42 Correct 14 ms 23800 KB Output is correct
43 Correct 17 ms 23800 KB Output is correct
44 Correct 14 ms 23800 KB Output is correct
45 Correct 14 ms 23800 KB Output is correct
46 Correct 16 ms 23820 KB Output is correct
47 Correct 16 ms 23800 KB Output is correct
48 Correct 13 ms 23756 KB Output is correct
49 Correct 14 ms 23808 KB Output is correct
50 Correct 15 ms 23892 KB Output is correct
51 Correct 17 ms 23884 KB Output is correct
52 Correct 15 ms 23924 KB Output is correct
53 Correct 15 ms 23884 KB Output is correct
54 Correct 15 ms 23884 KB Output is correct
55 Correct 16 ms 24052 KB Output is correct
56 Correct 18 ms 23944 KB Output is correct
57 Correct 16 ms 24024 KB Output is correct
58 Correct 14 ms 23796 KB Output is correct
59 Correct 14 ms 23800 KB Output is correct
60 Correct 14 ms 23740 KB Output is correct
61 Correct 15 ms 23924 KB Output is correct
62 Correct 14 ms 23844 KB Output is correct
63 Correct 14 ms 23756 KB Output is correct
64 Correct 14 ms 23728 KB Output is correct
65 Correct 15 ms 23884 KB Output is correct
66 Correct 14 ms 23768 KB Output is correct
67 Correct 14 ms 23788 KB Output is correct
68 Correct 14 ms 23744 KB Output is correct
69 Correct 14 ms 23776 KB Output is correct
70 Correct 15 ms 23796 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23756 KB Output is correct
2 Correct 14 ms 23736 KB Output is correct
3 Correct 14 ms 23796 KB Output is correct
4 Correct 14 ms 23800 KB Output is correct
5 Correct 15 ms 23804 KB Output is correct
6 Correct 14 ms 23756 KB Output is correct
7 Correct 14 ms 23756 KB Output is correct
8 Correct 13 ms 23756 KB Output is correct
9 Correct 14 ms 23796 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
11 Correct 14 ms 23796 KB Output is correct
12 Correct 14 ms 23804 KB Output is correct
13 Correct 14 ms 23760 KB Output is correct
14 Correct 15 ms 23756 KB Output is correct
15 Correct 14 ms 23756 KB Output is correct
16 Correct 14 ms 23756 KB Output is correct
17 Correct 15 ms 23784 KB Output is correct
18 Correct 14 ms 23800 KB Output is correct
19 Correct 15 ms 23756 KB Output is correct
20 Correct 14 ms 23796 KB Output is correct
21 Correct 14 ms 23692 KB Output is correct
22 Correct 14 ms 23756 KB Output is correct
23 Correct 14 ms 23756 KB Output is correct
24 Correct 14 ms 23692 KB Output is correct
25 Correct 13 ms 23756 KB Output is correct
26 Correct 16 ms 23800 KB Output is correct
27 Correct 14 ms 23744 KB Output is correct
28 Correct 15 ms 23884 KB Output is correct
29 Correct 15 ms 23800 KB Output is correct
30 Correct 14 ms 23764 KB Output is correct
31 Correct 15 ms 23760 KB Output is correct
32 Correct 16 ms 23756 KB Output is correct
33 Correct 16 ms 23836 KB Output is correct
34 Correct 14 ms 23796 KB Output is correct
35 Correct 14 ms 23728 KB Output is correct
36 Correct 15 ms 23800 KB Output is correct
37 Correct 14 ms 23716 KB Output is correct
38 Correct 14 ms 23756 KB Output is correct
39 Correct 14 ms 23776 KB Output is correct
40 Correct 14 ms 23756 KB Output is correct
41 Correct 14 ms 23752 KB Output is correct
42 Correct 14 ms 23800 KB Output is correct
43 Correct 17 ms 23800 KB Output is correct
44 Correct 14 ms 23800 KB Output is correct
45 Correct 14 ms 23800 KB Output is correct
46 Correct 16 ms 23820 KB Output is correct
47 Correct 16 ms 23800 KB Output is correct
48 Correct 13 ms 23756 KB Output is correct
49 Correct 14 ms 23808 KB Output is correct
50 Correct 15 ms 23892 KB Output is correct
51 Correct 17 ms 23884 KB Output is correct
52 Correct 15 ms 23924 KB Output is correct
53 Correct 15 ms 23884 KB Output is correct
54 Correct 15 ms 23884 KB Output is correct
55 Correct 16 ms 24052 KB Output is correct
56 Correct 18 ms 23944 KB Output is correct
57 Correct 16 ms 24024 KB Output is correct
58 Correct 14 ms 23796 KB Output is correct
59 Correct 14 ms 23800 KB Output is correct
60 Correct 14 ms 23740 KB Output is correct
61 Correct 15 ms 23924 KB Output is correct
62 Correct 14 ms 23844 KB Output is correct
63 Correct 14 ms 23756 KB Output is correct
64 Correct 14 ms 23728 KB Output is correct
65 Correct 15 ms 23884 KB Output is correct
66 Correct 14 ms 23768 KB Output is correct
67 Correct 14 ms 23788 KB Output is correct
68 Correct 14 ms 23744 KB Output is correct
69 Correct 14 ms 23776 KB Output is correct
70 Correct 15 ms 23796 KB Output is correct
71 Correct 206 ms 41196 KB Output is correct
72 Correct 147 ms 36740 KB Output is correct
73 Correct 195 ms 40932 KB Output is correct
74 Correct 116 ms 32704 KB Output is correct
75 Correct 131 ms 34456 KB Output is correct
76 Correct 320 ms 51048 KB Output is correct
77 Correct 289 ms 49032 KB Output is correct
78 Correct 260 ms 44984 KB Output is correct
79 Correct 247 ms 45524 KB Output is correct
80 Correct 14 ms 23756 KB Output is correct
81 Correct 15 ms 23856 KB Output is correct
82 Correct 16 ms 24012 KB Output is correct
83 Correct 40 ms 26308 KB Output is correct
84 Correct 48 ms 27236 KB Output is correct
85 Correct 24 ms 24504 KB Output is correct
86 Correct 14 ms 23756 KB Output is correct
87 Correct 52 ms 27296 KB Output is correct
88 Correct 14 ms 23724 KB Output is correct
89 Correct 14 ms 23728 KB Output is correct
90 Correct 15 ms 23756 KB Output is correct
91 Correct 23 ms 24652 KB Output is correct
92 Correct 59 ms 27572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23756 KB Output is correct
2 Correct 14 ms 23736 KB Output is correct
3 Correct 14 ms 23796 KB Output is correct
4 Correct 14 ms 23800 KB Output is correct
5 Correct 15 ms 23804 KB Output is correct
6 Correct 14 ms 23756 KB Output is correct
7 Correct 14 ms 23756 KB Output is correct
8 Correct 13 ms 23756 KB Output is correct
9 Correct 14 ms 23796 KB Output is correct
10 Correct 13 ms 23764 KB Output is correct
11 Correct 14 ms 23796 KB Output is correct
12 Correct 14 ms 23804 KB Output is correct
13 Correct 14 ms 23760 KB Output is correct
14 Correct 15 ms 23756 KB Output is correct
15 Correct 14 ms 23756 KB Output is correct
16 Correct 14 ms 23756 KB Output is correct
17 Correct 15 ms 23784 KB Output is correct
18 Correct 14 ms 23800 KB Output is correct
19 Correct 15 ms 23756 KB Output is correct
20 Correct 14 ms 23796 KB Output is correct
21 Correct 14 ms 23692 KB Output is correct
22 Correct 14 ms 23756 KB Output is correct
23 Correct 14 ms 23756 KB Output is correct
24 Correct 14 ms 23692 KB Output is correct
25 Correct 13 ms 23756 KB Output is correct
26 Correct 16 ms 23800 KB Output is correct
27 Correct 14 ms 23744 KB Output is correct
28 Correct 15 ms 23884 KB Output is correct
29 Correct 15 ms 23800 KB Output is correct
30 Correct 14 ms 23764 KB Output is correct
31 Correct 15 ms 23760 KB Output is correct
32 Correct 16 ms 23756 KB Output is correct
33 Correct 16 ms 23836 KB Output is correct
34 Correct 14 ms 23796 KB Output is correct
35 Correct 14 ms 23728 KB Output is correct
36 Correct 15 ms 23800 KB Output is correct
37 Correct 14 ms 23716 KB Output is correct
38 Correct 14 ms 23756 KB Output is correct
39 Correct 14 ms 23776 KB Output is correct
40 Correct 14 ms 23756 KB Output is correct
41 Correct 14 ms 23752 KB Output is correct
42 Correct 14 ms 23800 KB Output is correct
43 Correct 17 ms 23800 KB Output is correct
44 Correct 14 ms 23800 KB Output is correct
45 Correct 14 ms 23800 KB Output is correct
46 Correct 16 ms 23820 KB Output is correct
47 Correct 16 ms 23800 KB Output is correct
48 Correct 13 ms 23756 KB Output is correct
49 Correct 14 ms 23808 KB Output is correct
50 Correct 15 ms 23892 KB Output is correct
51 Correct 17 ms 23884 KB Output is correct
52 Correct 15 ms 23924 KB Output is correct
53 Correct 15 ms 23884 KB Output is correct
54 Correct 15 ms 23884 KB Output is correct
55 Correct 16 ms 24052 KB Output is correct
56 Correct 18 ms 23944 KB Output is correct
57 Correct 16 ms 24024 KB Output is correct
58 Correct 14 ms 23796 KB Output is correct
59 Correct 14 ms 23800 KB Output is correct
60 Correct 14 ms 23740 KB Output is correct
61 Correct 15 ms 23924 KB Output is correct
62 Correct 14 ms 23844 KB Output is correct
63 Correct 14 ms 23756 KB Output is correct
64 Correct 14 ms 23728 KB Output is correct
65 Correct 15 ms 23884 KB Output is correct
66 Correct 14 ms 23768 KB Output is correct
67 Correct 14 ms 23788 KB Output is correct
68 Correct 14 ms 23744 KB Output is correct
69 Correct 14 ms 23776 KB Output is correct
70 Correct 15 ms 23796 KB Output is correct
71 Correct 206 ms 41196 KB Output is correct
72 Correct 147 ms 36740 KB Output is correct
73 Correct 195 ms 40932 KB Output is correct
74 Correct 116 ms 32704 KB Output is correct
75 Correct 131 ms 34456 KB Output is correct
76 Correct 320 ms 51048 KB Output is correct
77 Correct 289 ms 49032 KB Output is correct
78 Correct 260 ms 44984 KB Output is correct
79 Correct 247 ms 45524 KB Output is correct
80 Correct 14 ms 23756 KB Output is correct
81 Correct 15 ms 23856 KB Output is correct
82 Correct 16 ms 24012 KB Output is correct
83 Correct 40 ms 26308 KB Output is correct
84 Correct 48 ms 27236 KB Output is correct
85 Correct 24 ms 24504 KB Output is correct
86 Correct 14 ms 23756 KB Output is correct
87 Correct 52 ms 27296 KB Output is correct
88 Correct 14 ms 23724 KB Output is correct
89 Correct 14 ms 23728 KB Output is correct
90 Correct 15 ms 23756 KB Output is correct
91 Correct 23 ms 24652 KB Output is correct
92 Correct 59 ms 27572 KB Output is correct
93 Correct 1101 ms 117372 KB Output is correct
94 Correct 629 ms 75464 KB Output is correct
95 Correct 700 ms 86848 KB Output is correct
96 Correct 658 ms 77640 KB Output is correct
97 Correct 590 ms 73840 KB Output is correct
98 Correct 1240 ms 130072 KB Output is correct
99 Correct 1302 ms 136868 KB Output is correct
100 Correct 1212 ms 128852 KB Output is correct
101 Correct 1212 ms 125128 KB Output is correct
102 Correct 1026 ms 113360 KB Output is correct
103 Correct 822 ms 95536 KB Output is correct
104 Correct 14 ms 23756 KB Output is correct
105 Correct 14 ms 23796 KB Output is correct
106 Correct 16 ms 24056 KB Output is correct
107 Correct 99 ms 31676 KB Output is correct
108 Correct 242 ms 42912 KB Output is correct
109 Correct 32 ms 25484 KB Output is correct
110 Correct 14 ms 23756 KB Output is correct
111 Correct 121 ms 33704 KB Output is correct
112 Correct 14 ms 23756 KB Output is correct
113 Correct 14 ms 23756 KB Output is correct
114 Correct 17 ms 23984 KB Output is correct
115 Correct 14 ms 23796 KB Output is correct
116 Correct 20 ms 24476 KB Output is correct
117 Correct 224 ms 41112 KB Output is correct