Submission #142895

# Submission time Handle Problem Language Result Execution time Memory
142895 2019-08-12T05:36:05 Z shayan_p Toys (CEOI18_toy) C++14
100 / 100
1126 ms 20188 KB
// only miss the sun when it starts to snow

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=1e5+10,mod=1e9+7;
const ll inf=1e18;

vector<int>vec, v[maxn], ans;
unordered_map<int,int> mp;

void solve(int id,int sm,int lim){
    if(id==0){
	ans.PB(sm);
	return;
    }
    for(int x:v[id]){
	if(x==1) continue;
	if(x>lim) break;
	solve( mp[ vec[id] / x ], sm + x -1, x);
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();

    int n; cin>>n;

    if(n==1) return cout<<1<<"\n"<<0<<endl,0;
    
    for(int i=1;i*i<=n;i++){
	if(n%i==0) vec.PB(i);
    }
    for(int i=sz(vec)-1;i>=0;i--){
	if(vec[i]*vec[i]!=n) vec.PB(n/vec[i]);
    }
    for(int i=0;i<sz(vec);i++){
	mp[vec[i]]=i;
    }
    
    for(int i=0;i<sz(vec);i++){
	for(int j=0;j<=i;j++)
	    if(vec[i] % vec[j] == 0) v[i].PB(vec[j]);
    }
    solve(sz(vec)-1,0,n);
    sort(ans.begin(), ans.end());
    ans.resize( unique(ans.begin(), ans.end()) - ans.begin() );
    cout<<sz(ans)<<"\n";
    for(int x:ans)
	cout<<x<<" ";
    return cout<<endl,0;
}
// Deathly mistakes:
//  * Read the problem carefully.
//  * Check maxn.
//  * Overflows.


// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2684 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
9 Correct 5 ms 2808 KB Output is correct
10 Correct 3 ms 2680 KB Output is correct
11 Correct 4 ms 2680 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Correct 4 ms 2652 KB Output is correct
14 Correct 5 ms 2656 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 4 ms 2680 KB Output is correct
17 Correct 4 ms 2684 KB Output is correct
18 Correct 4 ms 2680 KB Output is correct
19 Correct 4 ms 2680 KB Output is correct
20 Correct 5 ms 2680 KB Output is correct
21 Correct 4 ms 2680 KB Output is correct
22 Correct 4 ms 2680 KB Output is correct
23 Correct 4 ms 2808 KB Output is correct
24 Correct 4 ms 2680 KB Output is correct
25 Correct 4 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2684 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
9 Correct 5 ms 2808 KB Output is correct
10 Correct 3 ms 2680 KB Output is correct
11 Correct 4 ms 2680 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Correct 4 ms 2652 KB Output is correct
14 Correct 5 ms 2656 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 4 ms 2680 KB Output is correct
17 Correct 4 ms 2684 KB Output is correct
18 Correct 4 ms 2680 KB Output is correct
19 Correct 4 ms 2680 KB Output is correct
20 Correct 5 ms 2680 KB Output is correct
21 Correct 4 ms 2680 KB Output is correct
22 Correct 4 ms 2680 KB Output is correct
23 Correct 4 ms 2808 KB Output is correct
24 Correct 4 ms 2680 KB Output is correct
25 Correct 4 ms 2680 KB Output is correct
26 Correct 5 ms 2684 KB Output is correct
27 Correct 4 ms 2684 KB Output is correct
28 Correct 4 ms 2680 KB Output is correct
29 Correct 4 ms 2680 KB Output is correct
30 Correct 4 ms 2680 KB Output is correct
31 Correct 6 ms 2680 KB Output is correct
32 Correct 5 ms 2680 KB Output is correct
33 Correct 4 ms 2680 KB Output is correct
34 Correct 4 ms 2680 KB Output is correct
35 Correct 4 ms 2680 KB Output is correct
36 Correct 4 ms 2680 KB Output is correct
37 Correct 4 ms 2680 KB Output is correct
38 Correct 4 ms 2684 KB Output is correct
39 Correct 4 ms 2680 KB Output is correct
40 Correct 4 ms 2680 KB Output is correct
41 Correct 4 ms 2680 KB Output is correct
42 Correct 4 ms 2680 KB Output is correct
43 Correct 1 ms 2680 KB Output is correct
44 Correct 4 ms 2680 KB Output is correct
45 Correct 4 ms 2680 KB Output is correct
46 Correct 4 ms 2680 KB Output is correct
47 Correct 5 ms 2812 KB Output is correct
48 Correct 3 ms 2808 KB Output is correct
49 Correct 4 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2684 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
9 Correct 5 ms 2808 KB Output is correct
10 Correct 3 ms 2680 KB Output is correct
11 Correct 4 ms 2680 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Correct 4 ms 2652 KB Output is correct
14 Correct 5 ms 2656 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 4 ms 2680 KB Output is correct
17 Correct 4 ms 2684 KB Output is correct
18 Correct 4 ms 2680 KB Output is correct
19 Correct 4 ms 2680 KB Output is correct
20 Correct 5 ms 2680 KB Output is correct
21 Correct 4 ms 2680 KB Output is correct
22 Correct 4 ms 2680 KB Output is correct
23 Correct 4 ms 2808 KB Output is correct
24 Correct 4 ms 2680 KB Output is correct
25 Correct 4 ms 2680 KB Output is correct
26 Correct 5 ms 2684 KB Output is correct
27 Correct 4 ms 2684 KB Output is correct
28 Correct 4 ms 2680 KB Output is correct
29 Correct 4 ms 2680 KB Output is correct
30 Correct 4 ms 2680 KB Output is correct
31 Correct 6 ms 2680 KB Output is correct
32 Correct 5 ms 2680 KB Output is correct
33 Correct 4 ms 2680 KB Output is correct
34 Correct 4 ms 2680 KB Output is correct
35 Correct 4 ms 2680 KB Output is correct
36 Correct 4 ms 2680 KB Output is correct
37 Correct 4 ms 2680 KB Output is correct
38 Correct 4 ms 2684 KB Output is correct
39 Correct 4 ms 2680 KB Output is correct
40 Correct 4 ms 2680 KB Output is correct
41 Correct 4 ms 2680 KB Output is correct
42 Correct 4 ms 2680 KB Output is correct
43 Correct 1 ms 2680 KB Output is correct
44 Correct 4 ms 2680 KB Output is correct
45 Correct 4 ms 2680 KB Output is correct
46 Correct 4 ms 2680 KB Output is correct
47 Correct 5 ms 2812 KB Output is correct
48 Correct 3 ms 2808 KB Output is correct
49 Correct 4 ms 2680 KB Output is correct
50 Correct 5 ms 2680 KB Output is correct
51 Correct 5 ms 2728 KB Output is correct
52 Correct 5 ms 2680 KB Output is correct
53 Correct 5 ms 2680 KB Output is correct
54 Correct 5 ms 2680 KB Output is correct
55 Correct 6 ms 2808 KB Output is correct
56 Correct 6 ms 2808 KB Output is correct
57 Correct 5 ms 2808 KB Output is correct
58 Correct 7 ms 2808 KB Output is correct
59 Correct 4 ms 2728 KB Output is correct
60 Correct 4 ms 2684 KB Output is correct
61 Correct 6 ms 2680 KB Output is correct
62 Correct 5 ms 2680 KB Output is correct
63 Correct 5 ms 2680 KB Output is correct
64 Correct 4 ms 2680 KB Output is correct
65 Correct 5 ms 2680 KB Output is correct
66 Correct 2 ms 2680 KB Output is correct
67 Correct 4 ms 2680 KB Output is correct
68 Correct 5 ms 2684 KB Output is correct
69 Correct 3 ms 2680 KB Output is correct
70 Correct 5 ms 2680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2684 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
9 Correct 5 ms 2808 KB Output is correct
10 Correct 3 ms 2680 KB Output is correct
11 Correct 4 ms 2680 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Correct 4 ms 2652 KB Output is correct
14 Correct 5 ms 2656 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 4 ms 2680 KB Output is correct
17 Correct 4 ms 2684 KB Output is correct
18 Correct 4 ms 2680 KB Output is correct
19 Correct 4 ms 2680 KB Output is correct
20 Correct 5 ms 2680 KB Output is correct
21 Correct 4 ms 2680 KB Output is correct
22 Correct 4 ms 2680 KB Output is correct
23 Correct 4 ms 2808 KB Output is correct
24 Correct 4 ms 2680 KB Output is correct
25 Correct 4 ms 2680 KB Output is correct
26 Correct 5 ms 2684 KB Output is correct
27 Correct 4 ms 2684 KB Output is correct
28 Correct 4 ms 2680 KB Output is correct
29 Correct 4 ms 2680 KB Output is correct
30 Correct 4 ms 2680 KB Output is correct
31 Correct 6 ms 2680 KB Output is correct
32 Correct 5 ms 2680 KB Output is correct
33 Correct 4 ms 2680 KB Output is correct
34 Correct 4 ms 2680 KB Output is correct
35 Correct 4 ms 2680 KB Output is correct
36 Correct 4 ms 2680 KB Output is correct
37 Correct 4 ms 2680 KB Output is correct
38 Correct 4 ms 2684 KB Output is correct
39 Correct 4 ms 2680 KB Output is correct
40 Correct 4 ms 2680 KB Output is correct
41 Correct 4 ms 2680 KB Output is correct
42 Correct 4 ms 2680 KB Output is correct
43 Correct 1 ms 2680 KB Output is correct
44 Correct 4 ms 2680 KB Output is correct
45 Correct 4 ms 2680 KB Output is correct
46 Correct 4 ms 2680 KB Output is correct
47 Correct 5 ms 2812 KB Output is correct
48 Correct 3 ms 2808 KB Output is correct
49 Correct 4 ms 2680 KB Output is correct
50 Correct 5 ms 2680 KB Output is correct
51 Correct 5 ms 2728 KB Output is correct
52 Correct 5 ms 2680 KB Output is correct
53 Correct 5 ms 2680 KB Output is correct
54 Correct 5 ms 2680 KB Output is correct
55 Correct 6 ms 2808 KB Output is correct
56 Correct 6 ms 2808 KB Output is correct
57 Correct 5 ms 2808 KB Output is correct
58 Correct 7 ms 2808 KB Output is correct
59 Correct 4 ms 2728 KB Output is correct
60 Correct 4 ms 2684 KB Output is correct
61 Correct 6 ms 2680 KB Output is correct
62 Correct 5 ms 2680 KB Output is correct
63 Correct 5 ms 2680 KB Output is correct
64 Correct 4 ms 2680 KB Output is correct
65 Correct 5 ms 2680 KB Output is correct
66 Correct 2 ms 2680 KB Output is correct
67 Correct 4 ms 2680 KB Output is correct
68 Correct 5 ms 2684 KB Output is correct
69 Correct 3 ms 2680 KB Output is correct
70 Correct 5 ms 2680 KB Output is correct
71 Correct 96 ms 5228 KB Output is correct
72 Correct 61 ms 4084 KB Output is correct
73 Correct 126 ms 5428 KB Output is correct
74 Correct 53 ms 3572 KB Output is correct
75 Correct 68 ms 4208 KB Output is correct
76 Correct 198 ms 7240 KB Output is correct
77 Correct 270 ms 7420 KB Output is correct
78 Correct 169 ms 5228 KB Output is correct
79 Correct 162 ms 5108 KB Output is correct
80 Correct 4 ms 2680 KB Output is correct
81 Correct 5 ms 2680 KB Output is correct
82 Correct 5 ms 2808 KB Output is correct
83 Correct 24 ms 3192 KB Output is correct
84 Correct 23 ms 3316 KB Output is correct
85 Correct 7 ms 2808 KB Output is correct
86 Correct 5 ms 2680 KB Output is correct
87 Correct 21 ms 3192 KB Output is correct
88 Correct 4 ms 2680 KB Output is correct
89 Correct 4 ms 2680 KB Output is correct
90 Correct 4 ms 2680 KB Output is correct
91 Correct 8 ms 2936 KB Output is correct
92 Correct 21 ms 3196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 5 ms 2680 KB Output is correct
3 Correct 4 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2684 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
9 Correct 5 ms 2808 KB Output is correct
10 Correct 3 ms 2680 KB Output is correct
11 Correct 4 ms 2680 KB Output is correct
12 Correct 4 ms 2680 KB Output is correct
13 Correct 4 ms 2652 KB Output is correct
14 Correct 5 ms 2656 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 4 ms 2680 KB Output is correct
17 Correct 4 ms 2684 KB Output is correct
18 Correct 4 ms 2680 KB Output is correct
19 Correct 4 ms 2680 KB Output is correct
20 Correct 5 ms 2680 KB Output is correct
21 Correct 4 ms 2680 KB Output is correct
22 Correct 4 ms 2680 KB Output is correct
23 Correct 4 ms 2808 KB Output is correct
24 Correct 4 ms 2680 KB Output is correct
25 Correct 4 ms 2680 KB Output is correct
26 Correct 5 ms 2684 KB Output is correct
27 Correct 4 ms 2684 KB Output is correct
28 Correct 4 ms 2680 KB Output is correct
29 Correct 4 ms 2680 KB Output is correct
30 Correct 4 ms 2680 KB Output is correct
31 Correct 6 ms 2680 KB Output is correct
32 Correct 5 ms 2680 KB Output is correct
33 Correct 4 ms 2680 KB Output is correct
34 Correct 4 ms 2680 KB Output is correct
35 Correct 4 ms 2680 KB Output is correct
36 Correct 4 ms 2680 KB Output is correct
37 Correct 4 ms 2680 KB Output is correct
38 Correct 4 ms 2684 KB Output is correct
39 Correct 4 ms 2680 KB Output is correct
40 Correct 4 ms 2680 KB Output is correct
41 Correct 4 ms 2680 KB Output is correct
42 Correct 4 ms 2680 KB Output is correct
43 Correct 1 ms 2680 KB Output is correct
44 Correct 4 ms 2680 KB Output is correct
45 Correct 4 ms 2680 KB Output is correct
46 Correct 4 ms 2680 KB Output is correct
47 Correct 5 ms 2812 KB Output is correct
48 Correct 3 ms 2808 KB Output is correct
49 Correct 4 ms 2680 KB Output is correct
50 Correct 5 ms 2680 KB Output is correct
51 Correct 5 ms 2728 KB Output is correct
52 Correct 5 ms 2680 KB Output is correct
53 Correct 5 ms 2680 KB Output is correct
54 Correct 5 ms 2680 KB Output is correct
55 Correct 6 ms 2808 KB Output is correct
56 Correct 6 ms 2808 KB Output is correct
57 Correct 5 ms 2808 KB Output is correct
58 Correct 7 ms 2808 KB Output is correct
59 Correct 4 ms 2728 KB Output is correct
60 Correct 4 ms 2684 KB Output is correct
61 Correct 6 ms 2680 KB Output is correct
62 Correct 5 ms 2680 KB Output is correct
63 Correct 5 ms 2680 KB Output is correct
64 Correct 4 ms 2680 KB Output is correct
65 Correct 5 ms 2680 KB Output is correct
66 Correct 2 ms 2680 KB Output is correct
67 Correct 4 ms 2680 KB Output is correct
68 Correct 5 ms 2684 KB Output is correct
69 Correct 3 ms 2680 KB Output is correct
70 Correct 5 ms 2680 KB Output is correct
71 Correct 96 ms 5228 KB Output is correct
72 Correct 61 ms 4084 KB Output is correct
73 Correct 126 ms 5428 KB Output is correct
74 Correct 53 ms 3572 KB Output is correct
75 Correct 68 ms 4208 KB Output is correct
76 Correct 198 ms 7240 KB Output is correct
77 Correct 270 ms 7420 KB Output is correct
78 Correct 169 ms 5228 KB Output is correct
79 Correct 162 ms 5108 KB Output is correct
80 Correct 4 ms 2680 KB Output is correct
81 Correct 5 ms 2680 KB Output is correct
82 Correct 5 ms 2808 KB Output is correct
83 Correct 24 ms 3192 KB Output is correct
84 Correct 23 ms 3316 KB Output is correct
85 Correct 7 ms 2808 KB Output is correct
86 Correct 5 ms 2680 KB Output is correct
87 Correct 21 ms 3192 KB Output is correct
88 Correct 4 ms 2680 KB Output is correct
89 Correct 4 ms 2680 KB Output is correct
90 Correct 4 ms 2680 KB Output is correct
91 Correct 8 ms 2936 KB Output is correct
92 Correct 21 ms 3196 KB Output is correct
93 Correct 713 ms 12108 KB Output is correct
94 Correct 294 ms 7536 KB Output is correct
95 Correct 408 ms 11968 KB Output is correct
96 Correct 353 ms 7808 KB Output is correct
97 Correct 382 ms 7652 KB Output is correct
98 Correct 948 ms 20156 KB Output is correct
99 Correct 1048 ms 20064 KB Output is correct
100 Correct 1022 ms 20188 KB Output is correct
101 Correct 1126 ms 20020 KB Output is correct
102 Correct 1109 ms 19936 KB Output is correct
103 Correct 462 ms 11612 KB Output is correct
104 Correct 4 ms 2680 KB Output is correct
105 Correct 5 ms 2808 KB Output is correct
106 Correct 6 ms 2808 KB Output is correct
107 Correct 86 ms 3956 KB Output is correct
108 Correct 163 ms 5188 KB Output is correct
109 Correct 13 ms 2940 KB Output is correct
110 Correct 4 ms 2680 KB Output is correct
111 Correct 56 ms 3952 KB Output is correct
112 Correct 4 ms 2680 KB Output is correct
113 Correct 4 ms 2680 KB Output is correct
114 Correct 6 ms 2808 KB Output is correct
115 Correct 4 ms 2680 KB Output is correct
116 Correct 7 ms 2808 KB Output is correct
117 Correct 73 ms 4256 KB Output is correct