Submission #225770

# Submission time Handle Problem Language Result Execution time Memory
225770 2020-04-21T14:21:08 Z kshitij_sodani Toys (CEOI18_toy) C++17
79 / 100
5000 ms 70128 KB
#include <iostream>
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;

#define pb push_back
#define a first
#define b second
typedef int llo;
set<int> fin;
map<pair<int,int>,int> kk;
vector<llo> fac2[100000];
map<llo,llo> ss;
int rec(int nn,int su=0,int ma=0){
	if(kk[{nn,su}]==0){
		kk[{nn,su}]=1;
		if(nn==1){
			fin.insert(su);
		}
		else{
			for(int kk=fac2[ss[nn]].size()-1;kk>=0;kk--){
				int jj=fac2[ss[nn]][kk];
				if(jj==1){
					continue;
				}
				if(jj>=ma){
					rec(nn/jj,su+jj-1,jj);
				}
				else{
					break;
				}
			}
		}
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	llo n;
	cin>>n;
	vector<llo> fac;
	fac.clear();
	llo i=1;
	while(i*i<=n){
		if(n%i==0){
			fac.pb(i);
		
			fac.pb(n/i);
		//	cout<<n<<" "<<i<<endl;
		}
		i+=1;
	}
	
	llo k=-1;
	
	//n^(2/3) finding factors
	for(llo kk=0;kk<fac.size();kk++){
		llo nn=fac[kk];
		k+=1;
		ss[nn]=k;
		llo i=1;
		while(i*i<=n){
			if(nn%i==0){
				fac2[kk].pb(i);
				fac2[kk].pb(nn/i);
		//	cout<<n<<" "<<i<<endl;
		}
		i+=1;
	}

	for(int i=0;i<fac.size();i++){
		sort(fac2[i].begin(),fac2[i].end());
	}
		/*for(auto i:fac){
			if(nn%i==0){
				fac2[kk].pb(i);
			}
			i+=1;
		}*/
	}
	rec(n,0);
	//31*(n^1/3)*(n^(1/3))

/*	for(llo i=0;i<31;i++){
		for(llo j=0;j<fac.size();j++){
			if(i==0){
				dp[j][i].insert(fac[j]-1);
			}
			else{
				for(auto jj:fac2[j]){
					if(jj==1 or jj==fac[j]){
						continue;
					}
					for(auto kk:dp[ss[fac[j]/jj]][i-1]){
						dp[j][i].insert(kk+jj-1);
					}
				}
			}
		}
	}
	set<llo> ans;
	for(llo i=0;i<31;i++){
		for(auto jj:dp[ss[n]][i]){
			ans.insert(jj);
		}
	}*/
	cout<<fin.size()<<endl;

	for(auto ans2:fin){	
		cout<<ans2<<" ";
	}
	cout<<endl;;


	return 0;
}

Compilation message

toy.cpp: In function 'int rec(int, int, int)':
toy.cpp:35:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
toy.cpp: In function 'int main()':
toy.cpp:58:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(llo kk=0;kk<fac.size();kk++){
               ~~^~~~~~~~~~~
toy.cpp:72:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<fac.size();i++){
              ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 7 ms 2688 KB Output is correct
7 Correct 7 ms 2688 KB Output is correct
8 Correct 7 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 6 ms 2688 KB Output is correct
12 Correct 7 ms 2688 KB Output is correct
13 Correct 7 ms 2688 KB Output is correct
14 Correct 7 ms 2688 KB Output is correct
15 Correct 6 ms 2688 KB Output is correct
16 Correct 6 ms 2688 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 6 ms 2688 KB Output is correct
19 Correct 7 ms 2688 KB Output is correct
20 Correct 7 ms 2688 KB Output is correct
21 Correct 6 ms 2688 KB Output is correct
22 Correct 6 ms 2688 KB Output is correct
23 Correct 7 ms 2688 KB Output is correct
24 Correct 6 ms 2688 KB Output is correct
25 Correct 6 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 7 ms 2688 KB Output is correct
7 Correct 7 ms 2688 KB Output is correct
8 Correct 7 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 6 ms 2688 KB Output is correct
12 Correct 7 ms 2688 KB Output is correct
13 Correct 7 ms 2688 KB Output is correct
14 Correct 7 ms 2688 KB Output is correct
15 Correct 6 ms 2688 KB Output is correct
16 Correct 6 ms 2688 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 6 ms 2688 KB Output is correct
19 Correct 7 ms 2688 KB Output is correct
20 Correct 7 ms 2688 KB Output is correct
21 Correct 6 ms 2688 KB Output is correct
22 Correct 6 ms 2688 KB Output is correct
23 Correct 7 ms 2688 KB Output is correct
24 Correct 6 ms 2688 KB Output is correct
25 Correct 6 ms 2688 KB Output is correct
26 Correct 7 ms 2816 KB Output is correct
27 Correct 9 ms 2816 KB Output is correct
28 Correct 7 ms 2816 KB Output is correct
29 Correct 6 ms 2688 KB Output is correct
30 Correct 6 ms 2688 KB Output is correct
31 Correct 7 ms 2816 KB Output is correct
32 Correct 7 ms 2816 KB Output is correct
33 Correct 7 ms 2816 KB Output is correct
34 Correct 6 ms 2688 KB Output is correct
35 Correct 6 ms 2688 KB Output is correct
36 Correct 6 ms 2688 KB Output is correct
37 Correct 6 ms 2816 KB Output is correct
38 Correct 7 ms 2688 KB Output is correct
39 Correct 6 ms 2688 KB Output is correct
40 Correct 6 ms 2816 KB Output is correct
41 Correct 6 ms 2688 KB Output is correct
42 Correct 6 ms 2688 KB Output is correct
43 Correct 6 ms 2688 KB Output is correct
44 Correct 6 ms 2688 KB Output is correct
45 Correct 6 ms 2688 KB Output is correct
46 Correct 6 ms 2688 KB Output is correct
47 Correct 6 ms 2688 KB Output is correct
48 Correct 6 ms 2688 KB Output is correct
49 Correct 7 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 7 ms 2688 KB Output is correct
7 Correct 7 ms 2688 KB Output is correct
8 Correct 7 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 6 ms 2688 KB Output is correct
12 Correct 7 ms 2688 KB Output is correct
13 Correct 7 ms 2688 KB Output is correct
14 Correct 7 ms 2688 KB Output is correct
15 Correct 6 ms 2688 KB Output is correct
16 Correct 6 ms 2688 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 6 ms 2688 KB Output is correct
19 Correct 7 ms 2688 KB Output is correct
20 Correct 7 ms 2688 KB Output is correct
21 Correct 6 ms 2688 KB Output is correct
22 Correct 6 ms 2688 KB Output is correct
23 Correct 7 ms 2688 KB Output is correct
24 Correct 6 ms 2688 KB Output is correct
25 Correct 6 ms 2688 KB Output is correct
26 Correct 7 ms 2816 KB Output is correct
27 Correct 9 ms 2816 KB Output is correct
28 Correct 7 ms 2816 KB Output is correct
29 Correct 6 ms 2688 KB Output is correct
30 Correct 6 ms 2688 KB Output is correct
31 Correct 7 ms 2816 KB Output is correct
32 Correct 7 ms 2816 KB Output is correct
33 Correct 7 ms 2816 KB Output is correct
34 Correct 6 ms 2688 KB Output is correct
35 Correct 6 ms 2688 KB Output is correct
36 Correct 6 ms 2688 KB Output is correct
37 Correct 6 ms 2816 KB Output is correct
38 Correct 7 ms 2688 KB Output is correct
39 Correct 6 ms 2688 KB Output is correct
40 Correct 6 ms 2816 KB Output is correct
41 Correct 6 ms 2688 KB Output is correct
42 Correct 6 ms 2688 KB Output is correct
43 Correct 6 ms 2688 KB Output is correct
44 Correct 6 ms 2688 KB Output is correct
45 Correct 6 ms 2688 KB Output is correct
46 Correct 6 ms 2688 KB Output is correct
47 Correct 6 ms 2688 KB Output is correct
48 Correct 6 ms 2688 KB Output is correct
49 Correct 7 ms 2688 KB Output is correct
50 Correct 13 ms 3124 KB Output is correct
51 Correct 13 ms 3072 KB Output is correct
52 Correct 13 ms 3072 KB Output is correct
53 Correct 11 ms 3072 KB Output is correct
54 Correct 9 ms 2944 KB Output is correct
55 Correct 19 ms 3328 KB Output is correct
56 Correct 13 ms 3200 KB Output is correct
57 Correct 13 ms 3200 KB Output is correct
58 Correct 6 ms 2688 KB Output is correct
59 Correct 6 ms 2688 KB Output is correct
60 Correct 6 ms 2688 KB Output is correct
61 Correct 10 ms 2944 KB Output is correct
62 Correct 9 ms 2816 KB Output is correct
63 Correct 7 ms 2816 KB Output is correct
64 Correct 6 ms 2688 KB Output is correct
65 Correct 11 ms 2944 KB Output is correct
66 Correct 6 ms 2688 KB Output is correct
67 Correct 6 ms 2688 KB Output is correct
68 Correct 6 ms 2688 KB Output is correct
69 Correct 6 ms 2688 KB Output is correct
70 Correct 10 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 7 ms 2688 KB Output is correct
7 Correct 7 ms 2688 KB Output is correct
8 Correct 7 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 6 ms 2688 KB Output is correct
12 Correct 7 ms 2688 KB Output is correct
13 Correct 7 ms 2688 KB Output is correct
14 Correct 7 ms 2688 KB Output is correct
15 Correct 6 ms 2688 KB Output is correct
16 Correct 6 ms 2688 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 6 ms 2688 KB Output is correct
19 Correct 7 ms 2688 KB Output is correct
20 Correct 7 ms 2688 KB Output is correct
21 Correct 6 ms 2688 KB Output is correct
22 Correct 6 ms 2688 KB Output is correct
23 Correct 7 ms 2688 KB Output is correct
24 Correct 6 ms 2688 KB Output is correct
25 Correct 6 ms 2688 KB Output is correct
26 Correct 7 ms 2816 KB Output is correct
27 Correct 9 ms 2816 KB Output is correct
28 Correct 7 ms 2816 KB Output is correct
29 Correct 6 ms 2688 KB Output is correct
30 Correct 6 ms 2688 KB Output is correct
31 Correct 7 ms 2816 KB Output is correct
32 Correct 7 ms 2816 KB Output is correct
33 Correct 7 ms 2816 KB Output is correct
34 Correct 6 ms 2688 KB Output is correct
35 Correct 6 ms 2688 KB Output is correct
36 Correct 6 ms 2688 KB Output is correct
37 Correct 6 ms 2816 KB Output is correct
38 Correct 7 ms 2688 KB Output is correct
39 Correct 6 ms 2688 KB Output is correct
40 Correct 6 ms 2816 KB Output is correct
41 Correct 6 ms 2688 KB Output is correct
42 Correct 6 ms 2688 KB Output is correct
43 Correct 6 ms 2688 KB Output is correct
44 Correct 6 ms 2688 KB Output is correct
45 Correct 6 ms 2688 KB Output is correct
46 Correct 6 ms 2688 KB Output is correct
47 Correct 6 ms 2688 KB Output is correct
48 Correct 6 ms 2688 KB Output is correct
49 Correct 7 ms 2688 KB Output is correct
50 Correct 13 ms 3124 KB Output is correct
51 Correct 13 ms 3072 KB Output is correct
52 Correct 13 ms 3072 KB Output is correct
53 Correct 11 ms 3072 KB Output is correct
54 Correct 9 ms 2944 KB Output is correct
55 Correct 19 ms 3328 KB Output is correct
56 Correct 13 ms 3200 KB Output is correct
57 Correct 13 ms 3200 KB Output is correct
58 Correct 6 ms 2688 KB Output is correct
59 Correct 6 ms 2688 KB Output is correct
60 Correct 6 ms 2688 KB Output is correct
61 Correct 10 ms 2944 KB Output is correct
62 Correct 9 ms 2816 KB Output is correct
63 Correct 7 ms 2816 KB Output is correct
64 Correct 6 ms 2688 KB Output is correct
65 Correct 11 ms 2944 KB Output is correct
66 Correct 6 ms 2688 KB Output is correct
67 Correct 6 ms 2688 KB Output is correct
68 Correct 6 ms 2688 KB Output is correct
69 Correct 6 ms 2688 KB Output is correct
70 Correct 10 ms 2816 KB Output is correct
71 Correct 1217 ms 28524 KB Output is correct
72 Correct 874 ms 22368 KB Output is correct
73 Correct 990 ms 25568 KB Output is correct
74 Correct 587 ms 18040 KB Output is correct
75 Correct 681 ms 19064 KB Output is correct
76 Correct 1723 ms 37240 KB Output is correct
77 Correct 1338 ms 32940 KB Output is correct
78 Correct 1286 ms 31480 KB Output is correct
79 Correct 1213 ms 30448 KB Output is correct
80 Correct 6 ms 2688 KB Output is correct
81 Correct 6 ms 2688 KB Output is correct
82 Correct 12 ms 3200 KB Output is correct
83 Correct 85 ms 7416 KB Output is correct
84 Correct 136 ms 8568 KB Output is correct
85 Correct 30 ms 4480 KB Output is correct
86 Correct 10 ms 2816 KB Output is correct
87 Correct 133 ms 9464 KB Output is correct
88 Correct 7 ms 2688 KB Output is correct
89 Correct 7 ms 2688 KB Output is correct
90 Correct 9 ms 2688 KB Output is correct
91 Correct 66 ms 5368 KB Output is correct
92 Correct 341 ms 11768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 7 ms 2688 KB Output is correct
7 Correct 7 ms 2688 KB Output is correct
8 Correct 7 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 6 ms 2688 KB Output is correct
12 Correct 7 ms 2688 KB Output is correct
13 Correct 7 ms 2688 KB Output is correct
14 Correct 7 ms 2688 KB Output is correct
15 Correct 6 ms 2688 KB Output is correct
16 Correct 6 ms 2688 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 6 ms 2688 KB Output is correct
19 Correct 7 ms 2688 KB Output is correct
20 Correct 7 ms 2688 KB Output is correct
21 Correct 6 ms 2688 KB Output is correct
22 Correct 6 ms 2688 KB Output is correct
23 Correct 7 ms 2688 KB Output is correct
24 Correct 6 ms 2688 KB Output is correct
25 Correct 6 ms 2688 KB Output is correct
26 Correct 7 ms 2816 KB Output is correct
27 Correct 9 ms 2816 KB Output is correct
28 Correct 7 ms 2816 KB Output is correct
29 Correct 6 ms 2688 KB Output is correct
30 Correct 6 ms 2688 KB Output is correct
31 Correct 7 ms 2816 KB Output is correct
32 Correct 7 ms 2816 KB Output is correct
33 Correct 7 ms 2816 KB Output is correct
34 Correct 6 ms 2688 KB Output is correct
35 Correct 6 ms 2688 KB Output is correct
36 Correct 6 ms 2688 KB Output is correct
37 Correct 6 ms 2816 KB Output is correct
38 Correct 7 ms 2688 KB Output is correct
39 Correct 6 ms 2688 KB Output is correct
40 Correct 6 ms 2816 KB Output is correct
41 Correct 6 ms 2688 KB Output is correct
42 Correct 6 ms 2688 KB Output is correct
43 Correct 6 ms 2688 KB Output is correct
44 Correct 6 ms 2688 KB Output is correct
45 Correct 6 ms 2688 KB Output is correct
46 Correct 6 ms 2688 KB Output is correct
47 Correct 6 ms 2688 KB Output is correct
48 Correct 6 ms 2688 KB Output is correct
49 Correct 7 ms 2688 KB Output is correct
50 Correct 13 ms 3124 KB Output is correct
51 Correct 13 ms 3072 KB Output is correct
52 Correct 13 ms 3072 KB Output is correct
53 Correct 11 ms 3072 KB Output is correct
54 Correct 9 ms 2944 KB Output is correct
55 Correct 19 ms 3328 KB Output is correct
56 Correct 13 ms 3200 KB Output is correct
57 Correct 13 ms 3200 KB Output is correct
58 Correct 6 ms 2688 KB Output is correct
59 Correct 6 ms 2688 KB Output is correct
60 Correct 6 ms 2688 KB Output is correct
61 Correct 10 ms 2944 KB Output is correct
62 Correct 9 ms 2816 KB Output is correct
63 Correct 7 ms 2816 KB Output is correct
64 Correct 6 ms 2688 KB Output is correct
65 Correct 11 ms 2944 KB Output is correct
66 Correct 6 ms 2688 KB Output is correct
67 Correct 6 ms 2688 KB Output is correct
68 Correct 6 ms 2688 KB Output is correct
69 Correct 6 ms 2688 KB Output is correct
70 Correct 10 ms 2816 KB Output is correct
71 Correct 1217 ms 28524 KB Output is correct
72 Correct 874 ms 22368 KB Output is correct
73 Correct 990 ms 25568 KB Output is correct
74 Correct 587 ms 18040 KB Output is correct
75 Correct 681 ms 19064 KB Output is correct
76 Correct 1723 ms 37240 KB Output is correct
77 Correct 1338 ms 32940 KB Output is correct
78 Correct 1286 ms 31480 KB Output is correct
79 Correct 1213 ms 30448 KB Output is correct
80 Correct 6 ms 2688 KB Output is correct
81 Correct 6 ms 2688 KB Output is correct
82 Correct 12 ms 3200 KB Output is correct
83 Correct 85 ms 7416 KB Output is correct
84 Correct 136 ms 8568 KB Output is correct
85 Correct 30 ms 4480 KB Output is correct
86 Correct 10 ms 2816 KB Output is correct
87 Correct 133 ms 9464 KB Output is correct
88 Correct 7 ms 2688 KB Output is correct
89 Correct 7 ms 2688 KB Output is correct
90 Correct 9 ms 2688 KB Output is correct
91 Correct 66 ms 5368 KB Output is correct
92 Correct 341 ms 11768 KB Output is correct
93 Execution timed out 5073 ms 70128 KB Time limit exceeded
94 Halted 0 ms 0 KB -