Submission #538016

# Submission time Handle Problem Language Result Execution time Memory
538016 2022-03-16T03:09:43 Z jamielim Toys (CEOI18_toy) C++14
79 / 100
5000 ms 125344 KB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,ii> i4;
const int MOD=1000000007;
const int INF=1012345678;
const ll LLINF=1012345678012345678LL;
const double PI=3.1415926536;
const double EPS=1e-14;

int n;
vector<int> memo[5000005];

vector<int> dp(int n){
	if(n<5000005&&!memo[n].empty())return memo[n];
	set<int> s;
	for(int i=2;i*i<=n;i++){
		if(n%i!=0)continue;
		vector<int> y=dp(n/i);
		for(int j:y){
			s.insert(j+i-1);
		}
	}
	s.insert(n-1);
	
	vector<int> ans;
	for(int i:s)ans.pb(i);
	if(n<5000005)memo[n]=ans;
	return ans;
}

int main(){
	scanf("%d",&n);
	vector<int> ans=dp(n);
	sort(ALL(ans));
	printf("%d\n",SZ(ans));
	for(int i:ans){
		printf("%d ",i);
	}
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:41:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 58 ms 117644 KB Output is correct
2 Correct 58 ms 117664 KB Output is correct
3 Correct 63 ms 117652 KB Output is correct
4 Correct 61 ms 117588 KB Output is correct
5 Correct 68 ms 117604 KB Output is correct
6 Correct 58 ms 117704 KB Output is correct
7 Correct 57 ms 117608 KB Output is correct
8 Correct 58 ms 117596 KB Output is correct
9 Correct 67 ms 117672 KB Output is correct
10 Correct 62 ms 117604 KB Output is correct
11 Correct 58 ms 117624 KB Output is correct
12 Correct 64 ms 117700 KB Output is correct
13 Correct 60 ms 117712 KB Output is correct
14 Correct 59 ms 117676 KB Output is correct
15 Correct 58 ms 117676 KB Output is correct
16 Correct 60 ms 117684 KB Output is correct
17 Correct 60 ms 117696 KB Output is correct
18 Correct 58 ms 117672 KB Output is correct
19 Correct 61 ms 117616 KB Output is correct
20 Correct 60 ms 117588 KB Output is correct
21 Correct 59 ms 117580 KB Output is correct
22 Correct 58 ms 117640 KB Output is correct
23 Correct 58 ms 117648 KB Output is correct
24 Correct 60 ms 117696 KB Output is correct
25 Correct 59 ms 117696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 117644 KB Output is correct
2 Correct 58 ms 117664 KB Output is correct
3 Correct 63 ms 117652 KB Output is correct
4 Correct 61 ms 117588 KB Output is correct
5 Correct 68 ms 117604 KB Output is correct
6 Correct 58 ms 117704 KB Output is correct
7 Correct 57 ms 117608 KB Output is correct
8 Correct 58 ms 117596 KB Output is correct
9 Correct 67 ms 117672 KB Output is correct
10 Correct 62 ms 117604 KB Output is correct
11 Correct 58 ms 117624 KB Output is correct
12 Correct 64 ms 117700 KB Output is correct
13 Correct 60 ms 117712 KB Output is correct
14 Correct 59 ms 117676 KB Output is correct
15 Correct 58 ms 117676 KB Output is correct
16 Correct 60 ms 117684 KB Output is correct
17 Correct 60 ms 117696 KB Output is correct
18 Correct 58 ms 117672 KB Output is correct
19 Correct 61 ms 117616 KB Output is correct
20 Correct 60 ms 117588 KB Output is correct
21 Correct 59 ms 117580 KB Output is correct
22 Correct 58 ms 117640 KB Output is correct
23 Correct 58 ms 117648 KB Output is correct
24 Correct 60 ms 117696 KB Output is correct
25 Correct 59 ms 117696 KB Output is correct
26 Correct 60 ms 117612 KB Output is correct
27 Correct 58 ms 117692 KB Output is correct
28 Correct 68 ms 117664 KB Output is correct
29 Correct 60 ms 117708 KB Output is correct
30 Correct 60 ms 117688 KB Output is correct
31 Correct 59 ms 117708 KB Output is correct
32 Correct 60 ms 117664 KB Output is correct
33 Correct 62 ms 117668 KB Output is correct
34 Correct 59 ms 117580 KB Output is correct
35 Correct 60 ms 117676 KB Output is correct
36 Correct 62 ms 117640 KB Output is correct
37 Correct 59 ms 117616 KB Output is correct
38 Correct 60 ms 117708 KB Output is correct
39 Correct 62 ms 117580 KB Output is correct
40 Correct 69 ms 117680 KB Output is correct
41 Correct 59 ms 117604 KB Output is correct
42 Correct 60 ms 117756 KB Output is correct
43 Correct 59 ms 117768 KB Output is correct
44 Correct 68 ms 117580 KB Output is correct
45 Correct 67 ms 117636 KB Output is correct
46 Correct 60 ms 117604 KB Output is correct
47 Correct 58 ms 117588 KB Output is correct
48 Correct 61 ms 117716 KB Output is correct
49 Correct 60 ms 117612 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 117644 KB Output is correct
2 Correct 58 ms 117664 KB Output is correct
3 Correct 63 ms 117652 KB Output is correct
4 Correct 61 ms 117588 KB Output is correct
5 Correct 68 ms 117604 KB Output is correct
6 Correct 58 ms 117704 KB Output is correct
7 Correct 57 ms 117608 KB Output is correct
8 Correct 58 ms 117596 KB Output is correct
9 Correct 67 ms 117672 KB Output is correct
10 Correct 62 ms 117604 KB Output is correct
11 Correct 58 ms 117624 KB Output is correct
12 Correct 64 ms 117700 KB Output is correct
13 Correct 60 ms 117712 KB Output is correct
14 Correct 59 ms 117676 KB Output is correct
15 Correct 58 ms 117676 KB Output is correct
16 Correct 60 ms 117684 KB Output is correct
17 Correct 60 ms 117696 KB Output is correct
18 Correct 58 ms 117672 KB Output is correct
19 Correct 61 ms 117616 KB Output is correct
20 Correct 60 ms 117588 KB Output is correct
21 Correct 59 ms 117580 KB Output is correct
22 Correct 58 ms 117640 KB Output is correct
23 Correct 58 ms 117648 KB Output is correct
24 Correct 60 ms 117696 KB Output is correct
25 Correct 59 ms 117696 KB Output is correct
26 Correct 60 ms 117612 KB Output is correct
27 Correct 58 ms 117692 KB Output is correct
28 Correct 68 ms 117664 KB Output is correct
29 Correct 60 ms 117708 KB Output is correct
30 Correct 60 ms 117688 KB Output is correct
31 Correct 59 ms 117708 KB Output is correct
32 Correct 60 ms 117664 KB Output is correct
33 Correct 62 ms 117668 KB Output is correct
34 Correct 59 ms 117580 KB Output is correct
35 Correct 60 ms 117676 KB Output is correct
36 Correct 62 ms 117640 KB Output is correct
37 Correct 59 ms 117616 KB Output is correct
38 Correct 60 ms 117708 KB Output is correct
39 Correct 62 ms 117580 KB Output is correct
40 Correct 69 ms 117680 KB Output is correct
41 Correct 59 ms 117604 KB Output is correct
42 Correct 60 ms 117756 KB Output is correct
43 Correct 59 ms 117768 KB Output is correct
44 Correct 68 ms 117580 KB Output is correct
45 Correct 67 ms 117636 KB Output is correct
46 Correct 60 ms 117604 KB Output is correct
47 Correct 58 ms 117588 KB Output is correct
48 Correct 61 ms 117716 KB Output is correct
49 Correct 60 ms 117612 KB Output is correct
50 Correct 61 ms 117708 KB Output is correct
51 Correct 65 ms 117768 KB Output is correct
52 Correct 64 ms 117708 KB Output is correct
53 Correct 61 ms 117708 KB Output is correct
54 Correct 69 ms 117644 KB Output is correct
55 Correct 62 ms 117724 KB Output is correct
56 Correct 59 ms 117708 KB Output is correct
57 Correct 61 ms 117672 KB Output is correct
58 Correct 60 ms 117620 KB Output is correct
59 Correct 58 ms 117584 KB Output is correct
60 Correct 61 ms 117600 KB Output is correct
61 Correct 64 ms 117672 KB Output is correct
62 Correct 65 ms 117724 KB Output is correct
63 Correct 59 ms 117732 KB Output is correct
64 Correct 58 ms 117700 KB Output is correct
65 Correct 59 ms 117704 KB Output is correct
66 Correct 59 ms 117672 KB Output is correct
67 Correct 58 ms 117648 KB Output is correct
68 Correct 67 ms 117692 KB Output is correct
69 Correct 59 ms 117708 KB Output is correct
70 Correct 59 ms 117664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 117644 KB Output is correct
2 Correct 58 ms 117664 KB Output is correct
3 Correct 63 ms 117652 KB Output is correct
4 Correct 61 ms 117588 KB Output is correct
5 Correct 68 ms 117604 KB Output is correct
6 Correct 58 ms 117704 KB Output is correct
7 Correct 57 ms 117608 KB Output is correct
8 Correct 58 ms 117596 KB Output is correct
9 Correct 67 ms 117672 KB Output is correct
10 Correct 62 ms 117604 KB Output is correct
11 Correct 58 ms 117624 KB Output is correct
12 Correct 64 ms 117700 KB Output is correct
13 Correct 60 ms 117712 KB Output is correct
14 Correct 59 ms 117676 KB Output is correct
15 Correct 58 ms 117676 KB Output is correct
16 Correct 60 ms 117684 KB Output is correct
17 Correct 60 ms 117696 KB Output is correct
18 Correct 58 ms 117672 KB Output is correct
19 Correct 61 ms 117616 KB Output is correct
20 Correct 60 ms 117588 KB Output is correct
21 Correct 59 ms 117580 KB Output is correct
22 Correct 58 ms 117640 KB Output is correct
23 Correct 58 ms 117648 KB Output is correct
24 Correct 60 ms 117696 KB Output is correct
25 Correct 59 ms 117696 KB Output is correct
26 Correct 60 ms 117612 KB Output is correct
27 Correct 58 ms 117692 KB Output is correct
28 Correct 68 ms 117664 KB Output is correct
29 Correct 60 ms 117708 KB Output is correct
30 Correct 60 ms 117688 KB Output is correct
31 Correct 59 ms 117708 KB Output is correct
32 Correct 60 ms 117664 KB Output is correct
33 Correct 62 ms 117668 KB Output is correct
34 Correct 59 ms 117580 KB Output is correct
35 Correct 60 ms 117676 KB Output is correct
36 Correct 62 ms 117640 KB Output is correct
37 Correct 59 ms 117616 KB Output is correct
38 Correct 60 ms 117708 KB Output is correct
39 Correct 62 ms 117580 KB Output is correct
40 Correct 69 ms 117680 KB Output is correct
41 Correct 59 ms 117604 KB Output is correct
42 Correct 60 ms 117756 KB Output is correct
43 Correct 59 ms 117768 KB Output is correct
44 Correct 68 ms 117580 KB Output is correct
45 Correct 67 ms 117636 KB Output is correct
46 Correct 60 ms 117604 KB Output is correct
47 Correct 58 ms 117588 KB Output is correct
48 Correct 61 ms 117716 KB Output is correct
49 Correct 60 ms 117612 KB Output is correct
50 Correct 61 ms 117708 KB Output is correct
51 Correct 65 ms 117768 KB Output is correct
52 Correct 64 ms 117708 KB Output is correct
53 Correct 61 ms 117708 KB Output is correct
54 Correct 69 ms 117644 KB Output is correct
55 Correct 62 ms 117724 KB Output is correct
56 Correct 59 ms 117708 KB Output is correct
57 Correct 61 ms 117672 KB Output is correct
58 Correct 60 ms 117620 KB Output is correct
59 Correct 58 ms 117584 KB Output is correct
60 Correct 61 ms 117600 KB Output is correct
61 Correct 64 ms 117672 KB Output is correct
62 Correct 65 ms 117724 KB Output is correct
63 Correct 59 ms 117732 KB Output is correct
64 Correct 58 ms 117700 KB Output is correct
65 Correct 59 ms 117704 KB Output is correct
66 Correct 59 ms 117672 KB Output is correct
67 Correct 58 ms 117648 KB Output is correct
68 Correct 67 ms 117692 KB Output is correct
69 Correct 59 ms 117708 KB Output is correct
70 Correct 59 ms 117664 KB Output is correct
71 Correct 288 ms 120340 KB Output is correct
72 Correct 219 ms 119884 KB Output is correct
73 Correct 238 ms 120096 KB Output is correct
74 Correct 160 ms 119400 KB Output is correct
75 Correct 168 ms 119564 KB Output is correct
76 Correct 438 ms 121160 KB Output is correct
77 Correct 395 ms 120800 KB Output is correct
78 Correct 357 ms 120676 KB Output is correct
79 Correct 332 ms 120576 KB Output is correct
80 Correct 58 ms 117612 KB Output is correct
81 Correct 59 ms 117688 KB Output is correct
82 Correct 62 ms 117824 KB Output is correct
83 Correct 100 ms 118476 KB Output is correct
84 Correct 94 ms 118624 KB Output is correct
85 Correct 74 ms 118060 KB Output is correct
86 Correct 62 ms 117616 KB Output is correct
87 Correct 118 ms 118712 KB Output is correct
88 Correct 61 ms 117700 KB Output is correct
89 Correct 60 ms 117636 KB Output is correct
90 Correct 60 ms 117588 KB Output is correct
91 Correct 74 ms 118176 KB Output is correct
92 Correct 112 ms 118840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 117644 KB Output is correct
2 Correct 58 ms 117664 KB Output is correct
3 Correct 63 ms 117652 KB Output is correct
4 Correct 61 ms 117588 KB Output is correct
5 Correct 68 ms 117604 KB Output is correct
6 Correct 58 ms 117704 KB Output is correct
7 Correct 57 ms 117608 KB Output is correct
8 Correct 58 ms 117596 KB Output is correct
9 Correct 67 ms 117672 KB Output is correct
10 Correct 62 ms 117604 KB Output is correct
11 Correct 58 ms 117624 KB Output is correct
12 Correct 64 ms 117700 KB Output is correct
13 Correct 60 ms 117712 KB Output is correct
14 Correct 59 ms 117676 KB Output is correct
15 Correct 58 ms 117676 KB Output is correct
16 Correct 60 ms 117684 KB Output is correct
17 Correct 60 ms 117696 KB Output is correct
18 Correct 58 ms 117672 KB Output is correct
19 Correct 61 ms 117616 KB Output is correct
20 Correct 60 ms 117588 KB Output is correct
21 Correct 59 ms 117580 KB Output is correct
22 Correct 58 ms 117640 KB Output is correct
23 Correct 58 ms 117648 KB Output is correct
24 Correct 60 ms 117696 KB Output is correct
25 Correct 59 ms 117696 KB Output is correct
26 Correct 60 ms 117612 KB Output is correct
27 Correct 58 ms 117692 KB Output is correct
28 Correct 68 ms 117664 KB Output is correct
29 Correct 60 ms 117708 KB Output is correct
30 Correct 60 ms 117688 KB Output is correct
31 Correct 59 ms 117708 KB Output is correct
32 Correct 60 ms 117664 KB Output is correct
33 Correct 62 ms 117668 KB Output is correct
34 Correct 59 ms 117580 KB Output is correct
35 Correct 60 ms 117676 KB Output is correct
36 Correct 62 ms 117640 KB Output is correct
37 Correct 59 ms 117616 KB Output is correct
38 Correct 60 ms 117708 KB Output is correct
39 Correct 62 ms 117580 KB Output is correct
40 Correct 69 ms 117680 KB Output is correct
41 Correct 59 ms 117604 KB Output is correct
42 Correct 60 ms 117756 KB Output is correct
43 Correct 59 ms 117768 KB Output is correct
44 Correct 68 ms 117580 KB Output is correct
45 Correct 67 ms 117636 KB Output is correct
46 Correct 60 ms 117604 KB Output is correct
47 Correct 58 ms 117588 KB Output is correct
48 Correct 61 ms 117716 KB Output is correct
49 Correct 60 ms 117612 KB Output is correct
50 Correct 61 ms 117708 KB Output is correct
51 Correct 65 ms 117768 KB Output is correct
52 Correct 64 ms 117708 KB Output is correct
53 Correct 61 ms 117708 KB Output is correct
54 Correct 69 ms 117644 KB Output is correct
55 Correct 62 ms 117724 KB Output is correct
56 Correct 59 ms 117708 KB Output is correct
57 Correct 61 ms 117672 KB Output is correct
58 Correct 60 ms 117620 KB Output is correct
59 Correct 58 ms 117584 KB Output is correct
60 Correct 61 ms 117600 KB Output is correct
61 Correct 64 ms 117672 KB Output is correct
62 Correct 65 ms 117724 KB Output is correct
63 Correct 59 ms 117732 KB Output is correct
64 Correct 58 ms 117700 KB Output is correct
65 Correct 59 ms 117704 KB Output is correct
66 Correct 59 ms 117672 KB Output is correct
67 Correct 58 ms 117648 KB Output is correct
68 Correct 67 ms 117692 KB Output is correct
69 Correct 59 ms 117708 KB Output is correct
70 Correct 59 ms 117664 KB Output is correct
71 Correct 288 ms 120340 KB Output is correct
72 Correct 219 ms 119884 KB Output is correct
73 Correct 238 ms 120096 KB Output is correct
74 Correct 160 ms 119400 KB Output is correct
75 Correct 168 ms 119564 KB Output is correct
76 Correct 438 ms 121160 KB Output is correct
77 Correct 395 ms 120800 KB Output is correct
78 Correct 357 ms 120676 KB Output is correct
79 Correct 332 ms 120576 KB Output is correct
80 Correct 58 ms 117612 KB Output is correct
81 Correct 59 ms 117688 KB Output is correct
82 Correct 62 ms 117824 KB Output is correct
83 Correct 100 ms 118476 KB Output is correct
84 Correct 94 ms 118624 KB Output is correct
85 Correct 74 ms 118060 KB Output is correct
86 Correct 62 ms 117616 KB Output is correct
87 Correct 118 ms 118712 KB Output is correct
88 Correct 61 ms 117700 KB Output is correct
89 Correct 60 ms 117636 KB Output is correct
90 Correct 60 ms 117588 KB Output is correct
91 Correct 74 ms 118176 KB Output is correct
92 Correct 112 ms 118840 KB Output is correct
93 Execution timed out 5078 ms 125344 KB Time limit exceeded
94 Halted 0 ms 0 KB -