# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1068498 | 2024-08-21T10:18:30 Z | cpdreamer | Toys (CEOI18_toy) | C++14 | 5000 ms | 8640 KB |
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <utility> #define V vector #define F first #define S second #define P pair #define pb push_back #define all(v) v.begin(),v.end() typedef long long ll; using namespace __gnu_pbds; using namespace std; typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set; static int called = 0;const long long MOD = 1e9+7; // 1e9 + 7 void file(){ freopen("input.txt.txt","r",stdin); freopen("output.txt.txt","w",stdout); } ll binary_expo(ll a,ll b,ll m){ ll res=1; while(b){ if(b%2==1){res=(res*a)%m;b--;} b/=2; a=(a*a)%m; } return res; } bool prime(ll p){ for(int i=0;i<20;i++) { ll b = rand()%p; if(b!=0) { ll res = binary_expo(b, p, p); if (res != b % p) return false; } } return true; } void solve() { int n; cin>>n; if(n==1){ cout<<1<<endl; cout<<0<<endl; return; } V<int>primes; V<int>factor; primes.pb(2); primes.pb(3); for(int i=1;(6*i)-1<=n;i++){ if(prime((6*i)-1)) primes.pb((6*i)-1); if(prime((6*i)+1)) primes.pb((6*i)+1); } int p=0; while(n>1){ if(n%primes[p]==0){ n/=primes[p]; factor.pb(primes[p]); } else p++; } set<V<int>>st; st.insert({factor[0]}); for(int i=1;i<factor.size();i++) { set<V<int>>st1; for (auto &u: st) { for (int j=0;j<u.size();j++) { V<int>v=u; v[j]*=factor[i]; sort(all(v)); st1.insert(v); } V<int>v=u; v.pb(factor[i]); sort(all(v)); st1.insert(v); } st=st1; } V<int>ans; for(auto u:st) { int c = 0; for (auto x: u) { c += x - 1; } ans.pb(c); } sort(all(ans)); auto it=unique(all(ans)); ans.resize(distance(ans.begin(),it)); cout<<ans.size()<<endl; for(auto u:ans) cout<<u<<" "; cout<<endl; } int main(){ //file(); solve(); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 436 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 344 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 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 | 1 ms | 432 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 344 KB | Output is correct |
24 | Correct | 1 ms | 440 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 436 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 344 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 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 | 1 ms | 432 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 344 KB | Output is correct |
24 | Correct | 1 ms | 440 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 2 ms | 348 KB | Output is correct |
27 | Correct | 1 ms | 444 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 1 ms | 348 KB | Output is correct |
31 | Correct | 3 ms | 448 KB | Output is correct |
32 | Correct | 2 ms | 348 KB | Output is correct |
33 | Correct | 2 ms | 348 KB | Output is correct |
34 | Correct | 2 ms | 348 KB | Output is correct |
35 | Correct | 2 ms | 348 KB | Output is correct |
36 | Correct | 3 ms | 348 KB | Output is correct |
37 | Correct | 3 ms | 348 KB | Output is correct |
38 | Correct | 2 ms | 436 KB | Output is correct |
39 | Correct | 2 ms | 348 KB | Output is correct |
40 | Correct | 2 ms | 444 KB | Output is correct |
41 | Correct | 2 ms | 348 KB | Output is correct |
42 | Correct | 2 ms | 348 KB | Output is correct |
43 | Correct | 2 ms | 348 KB | Output is correct |
44 | Correct | 2 ms | 348 KB | Output is correct |
45 | Correct | 2 ms | 348 KB | Output is correct |
46 | Correct | 2 ms | 348 KB | Output is correct |
47 | Correct | 3 ms | 348 KB | Output is correct |
48 | Correct | 2 ms | 348 KB | Output is correct |
49 | Correct | 2 ms | 436 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 436 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 344 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 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 | 1 ms | 432 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 344 KB | Output is correct |
24 | Correct | 1 ms | 440 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 2 ms | 348 KB | Output is correct |
27 | Correct | 1 ms | 444 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 1 ms | 348 KB | Output is correct |
31 | Correct | 3 ms | 448 KB | Output is correct |
32 | Correct | 2 ms | 348 KB | Output is correct |
33 | Correct | 2 ms | 348 KB | Output is correct |
34 | Correct | 2 ms | 348 KB | Output is correct |
35 | Correct | 2 ms | 348 KB | Output is correct |
36 | Correct | 3 ms | 348 KB | Output is correct |
37 | Correct | 3 ms | 348 KB | Output is correct |
38 | Correct | 2 ms | 436 KB | Output is correct |
39 | Correct | 2 ms | 348 KB | Output is correct |
40 | Correct | 2 ms | 444 KB | Output is correct |
41 | Correct | 2 ms | 348 KB | Output is correct |
42 | Correct | 2 ms | 348 KB | Output is correct |
43 | Correct | 2 ms | 348 KB | Output is correct |
44 | Correct | 2 ms | 348 KB | Output is correct |
45 | Correct | 2 ms | 348 KB | Output is correct |
46 | Correct | 2 ms | 348 KB | Output is correct |
47 | Correct | 3 ms | 348 KB | Output is correct |
48 | Correct | 2 ms | 348 KB | Output is correct |
49 | Correct | 2 ms | 436 KB | Output is correct |
50 | Correct | 15 ms | 696 KB | Output is correct |
51 | Correct | 10 ms | 688 KB | Output is correct |
52 | Correct | 10 ms | 860 KB | Output is correct |
53 | Correct | 8 ms | 720 KB | Output is correct |
54 | Correct | 6 ms | 448 KB | Output is correct |
55 | Correct | 17 ms | 1008 KB | Output is correct |
56 | Correct | 16 ms | 1116 KB | Output is correct |
57 | Correct | 15 ms | 988 KB | Output is correct |
58 | Correct | 17 ms | 540 KB | Output is correct |
59 | Correct | 16 ms | 504 KB | Output is correct |
60 | Correct | 13 ms | 496 KB | Output is correct |
61 | Correct | 18 ms | 612 KB | Output is correct |
62 | Correct | 5 ms | 360 KB | Output is correct |
63 | Correct | 18 ms | 452 KB | Output is correct |
64 | Correct | 17 ms | 348 KB | Output is correct |
65 | Correct | 17 ms | 728 KB | Output is correct |
66 | Correct | 16 ms | 356 KB | Output is correct |
67 | Correct | 21 ms | 344 KB | Output is correct |
68 | Correct | 17 ms | 348 KB | Output is correct |
69 | Correct | 17 ms | 348 KB | Output is correct |
70 | Correct | 16 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 436 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 344 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 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 | 1 ms | 432 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 344 KB | Output is correct |
24 | Correct | 1 ms | 440 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 2 ms | 348 KB | Output is correct |
27 | Correct | 1 ms | 444 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 1 ms | 348 KB | Output is correct |
31 | Correct | 3 ms | 448 KB | Output is correct |
32 | Correct | 2 ms | 348 KB | Output is correct |
33 | Correct | 2 ms | 348 KB | Output is correct |
34 | Correct | 2 ms | 348 KB | Output is correct |
35 | Correct | 2 ms | 348 KB | Output is correct |
36 | Correct | 3 ms | 348 KB | Output is correct |
37 | Correct | 3 ms | 348 KB | Output is correct |
38 | Correct | 2 ms | 436 KB | Output is correct |
39 | Correct | 2 ms | 348 KB | Output is correct |
40 | Correct | 2 ms | 444 KB | Output is correct |
41 | Correct | 2 ms | 348 KB | Output is correct |
42 | Correct | 2 ms | 348 KB | Output is correct |
43 | Correct | 2 ms | 348 KB | Output is correct |
44 | Correct | 2 ms | 348 KB | Output is correct |
45 | Correct | 2 ms | 348 KB | Output is correct |
46 | Correct | 2 ms | 348 KB | Output is correct |
47 | Correct | 3 ms | 348 KB | Output is correct |
48 | Correct | 2 ms | 348 KB | Output is correct |
49 | Correct | 2 ms | 436 KB | Output is correct |
50 | Correct | 15 ms | 696 KB | Output is correct |
51 | Correct | 10 ms | 688 KB | Output is correct |
52 | Correct | 10 ms | 860 KB | Output is correct |
53 | Correct | 8 ms | 720 KB | Output is correct |
54 | Correct | 6 ms | 448 KB | Output is correct |
55 | Correct | 17 ms | 1008 KB | Output is correct |
56 | Correct | 16 ms | 1116 KB | Output is correct |
57 | Correct | 15 ms | 988 KB | Output is correct |
58 | Correct | 17 ms | 540 KB | Output is correct |
59 | Correct | 16 ms | 504 KB | Output is correct |
60 | Correct | 13 ms | 496 KB | Output is correct |
61 | Correct | 18 ms | 612 KB | Output is correct |
62 | Correct | 5 ms | 360 KB | Output is correct |
63 | Correct | 18 ms | 452 KB | Output is correct |
64 | Correct | 17 ms | 348 KB | Output is correct |
65 | Correct | 17 ms | 728 KB | Output is correct |
66 | Correct | 16 ms | 356 KB | Output is correct |
67 | Correct | 21 ms | 344 KB | Output is correct |
68 | Correct | 17 ms | 348 KB | Output is correct |
69 | Correct | 17 ms | 348 KB | Output is correct |
70 | Correct | 16 ms | 492 KB | Output is correct |
71 | Execution timed out | 5032 ms | 8640 KB | Time limit exceeded |
72 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 436 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 344 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 344 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 1 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 | 1 ms | 432 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 344 KB | Output is correct |
24 | Correct | 1 ms | 440 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 2 ms | 348 KB | Output is correct |
27 | Correct | 1 ms | 444 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 1 ms | 348 KB | Output is correct |
31 | Correct | 3 ms | 448 KB | Output is correct |
32 | Correct | 2 ms | 348 KB | Output is correct |
33 | Correct | 2 ms | 348 KB | Output is correct |
34 | Correct | 2 ms | 348 KB | Output is correct |
35 | Correct | 2 ms | 348 KB | Output is correct |
36 | Correct | 3 ms | 348 KB | Output is correct |
37 | Correct | 3 ms | 348 KB | Output is correct |
38 | Correct | 2 ms | 436 KB | Output is correct |
39 | Correct | 2 ms | 348 KB | Output is correct |
40 | Correct | 2 ms | 444 KB | Output is correct |
41 | Correct | 2 ms | 348 KB | Output is correct |
42 | Correct | 2 ms | 348 KB | Output is correct |
43 | Correct | 2 ms | 348 KB | Output is correct |
44 | Correct | 2 ms | 348 KB | Output is correct |
45 | Correct | 2 ms | 348 KB | Output is correct |
46 | Correct | 2 ms | 348 KB | Output is correct |
47 | Correct | 3 ms | 348 KB | Output is correct |
48 | Correct | 2 ms | 348 KB | Output is correct |
49 | Correct | 2 ms | 436 KB | Output is correct |
50 | Correct | 15 ms | 696 KB | Output is correct |
51 | Correct | 10 ms | 688 KB | Output is correct |
52 | Correct | 10 ms | 860 KB | Output is correct |
53 | Correct | 8 ms | 720 KB | Output is correct |
54 | Correct | 6 ms | 448 KB | Output is correct |
55 | Correct | 17 ms | 1008 KB | Output is correct |
56 | Correct | 16 ms | 1116 KB | Output is correct |
57 | Correct | 15 ms | 988 KB | Output is correct |
58 | Correct | 17 ms | 540 KB | Output is correct |
59 | Correct | 16 ms | 504 KB | Output is correct |
60 | Correct | 13 ms | 496 KB | Output is correct |
61 | Correct | 18 ms | 612 KB | Output is correct |
62 | Correct | 5 ms | 360 KB | Output is correct |
63 | Correct | 18 ms | 452 KB | Output is correct |
64 | Correct | 17 ms | 348 KB | Output is correct |
65 | Correct | 17 ms | 728 KB | Output is correct |
66 | Correct | 16 ms | 356 KB | Output is correct |
67 | Correct | 21 ms | 344 KB | Output is correct |
68 | Correct | 17 ms | 348 KB | Output is correct |
69 | Correct | 17 ms | 348 KB | Output is correct |
70 | Correct | 16 ms | 492 KB | Output is correct |
71 | Execution timed out | 5032 ms | 8640 KB | Time limit exceeded |
72 | Halted | 0 ms | 0 KB | - |