Submission #225771

# Submission time Handle Problem Language Result Execution time Memory
225771 2020-04-21T14:24:04 Z kshitij_sodani Toys (CEOI18_toy) C++17
79 / 100
5000 ms 76824 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);
			/*	}
				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++){
               ~~^~~~~~~~~~~
# 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 6 ms 2688 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 6 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 5 ms 2688 KB Output is correct
12 Correct 6 ms 2688 KB Output is correct
13 Correct 6 ms 2688 KB Output is correct
14 Correct 6 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 6 ms 2688 KB Output is correct
20 Correct 6 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 5 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 6 ms 2688 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 6 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 5 ms 2688 KB Output is correct
12 Correct 6 ms 2688 KB Output is correct
13 Correct 6 ms 2688 KB Output is correct
14 Correct 6 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 6 ms 2688 KB Output is correct
20 Correct 6 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 5 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 7 ms 2816 KB Output is correct
28 Correct 6 ms 2688 KB Output is correct
29 Correct 6 ms 2688 KB Output is correct
30 Correct 6 ms 2688 KB Output is correct
31 Correct 8 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 7 ms 2688 KB Output is correct
38 Correct 6 ms 2688 KB Output is correct
39 Correct 6 ms 2688 KB Output is correct
40 Correct 7 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 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 6 ms 2688 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 6 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 5 ms 2688 KB Output is correct
12 Correct 6 ms 2688 KB Output is correct
13 Correct 6 ms 2688 KB Output is correct
14 Correct 6 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 6 ms 2688 KB Output is correct
20 Correct 6 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 5 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 7 ms 2816 KB Output is correct
28 Correct 6 ms 2688 KB Output is correct
29 Correct 6 ms 2688 KB Output is correct
30 Correct 6 ms 2688 KB Output is correct
31 Correct 8 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 7 ms 2688 KB Output is correct
38 Correct 6 ms 2688 KB Output is correct
39 Correct 6 ms 2688 KB Output is correct
40 Correct 7 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 6 ms 2688 KB Output is correct
50 Correct 16 ms 3072 KB Output is correct
51 Correct 16 ms 3072 KB Output is correct
52 Correct 15 ms 3072 KB Output is correct
53 Correct 14 ms 3072 KB Output is correct
54 Correct 9 ms 2944 KB Output is correct
55 Correct 20 ms 3200 KB Output is correct
56 Correct 19 ms 3200 KB Output is correct
57 Correct 17 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 11 ms 3072 KB Output is correct
62 Correct 8 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 8 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 6 ms 2688 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 6 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 5 ms 2688 KB Output is correct
12 Correct 6 ms 2688 KB Output is correct
13 Correct 6 ms 2688 KB Output is correct
14 Correct 6 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 6 ms 2688 KB Output is correct
20 Correct 6 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 5 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 7 ms 2816 KB Output is correct
28 Correct 6 ms 2688 KB Output is correct
29 Correct 6 ms 2688 KB Output is correct
30 Correct 6 ms 2688 KB Output is correct
31 Correct 8 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 7 ms 2688 KB Output is correct
38 Correct 6 ms 2688 KB Output is correct
39 Correct 6 ms 2688 KB Output is correct
40 Correct 7 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 6 ms 2688 KB Output is correct
50 Correct 16 ms 3072 KB Output is correct
51 Correct 16 ms 3072 KB Output is correct
52 Correct 15 ms 3072 KB Output is correct
53 Correct 14 ms 3072 KB Output is correct
54 Correct 9 ms 2944 KB Output is correct
55 Correct 20 ms 3200 KB Output is correct
56 Correct 19 ms 3200 KB Output is correct
57 Correct 17 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 11 ms 3072 KB Output is correct
62 Correct 8 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 8 ms 2816 KB Output is correct
71 Correct 2358 ms 28456 KB Output is correct
72 Correct 1521 ms 22264 KB Output is correct
73 Correct 2201 ms 25668 KB Output is correct
74 Correct 1107 ms 18044 KB Output is correct
75 Correct 1307 ms 19100 KB Output is correct
76 Correct 4002 ms 37076 KB Output is correct
77 Correct 3524 ms 32932 KB Output is correct
78 Correct 3008 ms 31736 KB Output is correct
79 Correct 2870 ms 30428 KB Output is correct
80 Correct 6 ms 2688 KB Output is correct
81 Correct 6 ms 2688 KB Output is correct
82 Correct 16 ms 3200 KB Output is correct
83 Correct 218 ms 7416 KB Output is correct
84 Correct 304 ms 8568 KB Output is correct
85 Correct 58 ms 4472 KB Output is correct
86 Correct 9 ms 2688 KB Output is correct
87 Correct 328 ms 9456 KB Output is correct
88 Correct 7 ms 2688 KB Output is correct
89 Correct 6 ms 2688 KB Output is correct
90 Correct 9 ms 2688 KB Output is correct
91 Correct 88 ms 5496 KB Output is correct
92 Correct 459 ms 11772 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 6 ms 2688 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 6 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 5 ms 2688 KB Output is correct
12 Correct 6 ms 2688 KB Output is correct
13 Correct 6 ms 2688 KB Output is correct
14 Correct 6 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 6 ms 2688 KB Output is correct
20 Correct 6 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 5 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 7 ms 2816 KB Output is correct
28 Correct 6 ms 2688 KB Output is correct
29 Correct 6 ms 2688 KB Output is correct
30 Correct 6 ms 2688 KB Output is correct
31 Correct 8 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 7 ms 2688 KB Output is correct
38 Correct 6 ms 2688 KB Output is correct
39 Correct 6 ms 2688 KB Output is correct
40 Correct 7 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 6 ms 2688 KB Output is correct
50 Correct 16 ms 3072 KB Output is correct
51 Correct 16 ms 3072 KB Output is correct
52 Correct 15 ms 3072 KB Output is correct
53 Correct 14 ms 3072 KB Output is correct
54 Correct 9 ms 2944 KB Output is correct
55 Correct 20 ms 3200 KB Output is correct
56 Correct 19 ms 3200 KB Output is correct
57 Correct 17 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 11 ms 3072 KB Output is correct
62 Correct 8 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 8 ms 2816 KB Output is correct
71 Correct 2358 ms 28456 KB Output is correct
72 Correct 1521 ms 22264 KB Output is correct
73 Correct 2201 ms 25668 KB Output is correct
74 Correct 1107 ms 18044 KB Output is correct
75 Correct 1307 ms 19100 KB Output is correct
76 Correct 4002 ms 37076 KB Output is correct
77 Correct 3524 ms 32932 KB Output is correct
78 Correct 3008 ms 31736 KB Output is correct
79 Correct 2870 ms 30428 KB Output is correct
80 Correct 6 ms 2688 KB Output is correct
81 Correct 6 ms 2688 KB Output is correct
82 Correct 16 ms 3200 KB Output is correct
83 Correct 218 ms 7416 KB Output is correct
84 Correct 304 ms 8568 KB Output is correct
85 Correct 58 ms 4472 KB Output is correct
86 Correct 9 ms 2688 KB Output is correct
87 Correct 328 ms 9456 KB Output is correct
88 Correct 7 ms 2688 KB Output is correct
89 Correct 6 ms 2688 KB Output is correct
90 Correct 9 ms 2688 KB Output is correct
91 Correct 88 ms 5496 KB Output is correct
92 Correct 459 ms 11772 KB Output is correct
93 Execution timed out 5072 ms 76824 KB Time limit exceeded
94 Halted 0 ms 0 KB -