Submission #538014

# Submission time Handle Problem Language Result Execution time Memory
538014 2022-03-16T03:08:08 Z jamielim Toys (CEOI18_toy) C++14
59 / 100
5000 ms 120940 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<100005&&!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 62 ms 117684 KB Output is correct
2 Correct 61 ms 117588 KB Output is correct
3 Correct 62 ms 117608 KB Output is correct
4 Correct 68 ms 117636 KB Output is correct
5 Correct 58 ms 117580 KB Output is correct
6 Correct 60 ms 117704 KB Output is correct
7 Correct 62 ms 117584 KB Output is correct
8 Correct 62 ms 117612 KB Output is correct
9 Correct 62 ms 117716 KB Output is correct
10 Correct 59 ms 117580 KB Output is correct
11 Correct 58 ms 117680 KB Output is correct
12 Correct 59 ms 117748 KB Output is correct
13 Correct 61 ms 117688 KB Output is correct
14 Correct 62 ms 117580 KB Output is correct
15 Correct 63 ms 117700 KB Output is correct
16 Correct 61 ms 117688 KB Output is correct
17 Correct 59 ms 117704 KB Output is correct
18 Correct 64 ms 117696 KB Output is correct
19 Correct 61 ms 117680 KB Output is correct
20 Correct 69 ms 117692 KB Output is correct
21 Correct 62 ms 117692 KB Output is correct
22 Correct 59 ms 117592 KB Output is correct
23 Correct 61 ms 117700 KB Output is correct
24 Correct 61 ms 117616 KB Output is correct
25 Correct 59 ms 117580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 117684 KB Output is correct
2 Correct 61 ms 117588 KB Output is correct
3 Correct 62 ms 117608 KB Output is correct
4 Correct 68 ms 117636 KB Output is correct
5 Correct 58 ms 117580 KB Output is correct
6 Correct 60 ms 117704 KB Output is correct
7 Correct 62 ms 117584 KB Output is correct
8 Correct 62 ms 117612 KB Output is correct
9 Correct 62 ms 117716 KB Output is correct
10 Correct 59 ms 117580 KB Output is correct
11 Correct 58 ms 117680 KB Output is correct
12 Correct 59 ms 117748 KB Output is correct
13 Correct 61 ms 117688 KB Output is correct
14 Correct 62 ms 117580 KB Output is correct
15 Correct 63 ms 117700 KB Output is correct
16 Correct 61 ms 117688 KB Output is correct
17 Correct 59 ms 117704 KB Output is correct
18 Correct 64 ms 117696 KB Output is correct
19 Correct 61 ms 117680 KB Output is correct
20 Correct 69 ms 117692 KB Output is correct
21 Correct 62 ms 117692 KB Output is correct
22 Correct 59 ms 117592 KB Output is correct
23 Correct 61 ms 117700 KB Output is correct
24 Correct 61 ms 117616 KB Output is correct
25 Correct 59 ms 117580 KB Output is correct
26 Correct 59 ms 117656 KB Output is correct
27 Correct 63 ms 117616 KB Output is correct
28 Correct 63 ms 117712 KB Output is correct
29 Correct 70 ms 117696 KB Output is correct
30 Correct 61 ms 117660 KB Output is correct
31 Correct 62 ms 117640 KB Output is correct
32 Correct 60 ms 117720 KB Output is correct
33 Correct 66 ms 117716 KB Output is correct
34 Correct 64 ms 117736 KB Output is correct
35 Correct 67 ms 117592 KB Output is correct
36 Correct 59 ms 117688 KB Output is correct
37 Correct 66 ms 117708 KB Output is correct
38 Correct 59 ms 117708 KB Output is correct
39 Correct 60 ms 117644 KB Output is correct
40 Correct 68 ms 117720 KB Output is correct
41 Correct 61 ms 117632 KB Output is correct
42 Correct 58 ms 117656 KB Output is correct
43 Correct 59 ms 117676 KB Output is correct
44 Correct 61 ms 117600 KB Output is correct
45 Correct 59 ms 117712 KB Output is correct
46 Correct 58 ms 117696 KB Output is correct
47 Correct 59 ms 117704 KB Output is correct
48 Correct 62 ms 117696 KB Output is correct
49 Correct 61 ms 117592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 117684 KB Output is correct
2 Correct 61 ms 117588 KB Output is correct
3 Correct 62 ms 117608 KB Output is correct
4 Correct 68 ms 117636 KB Output is correct
5 Correct 58 ms 117580 KB Output is correct
6 Correct 60 ms 117704 KB Output is correct
7 Correct 62 ms 117584 KB Output is correct
8 Correct 62 ms 117612 KB Output is correct
9 Correct 62 ms 117716 KB Output is correct
10 Correct 59 ms 117580 KB Output is correct
11 Correct 58 ms 117680 KB Output is correct
12 Correct 59 ms 117748 KB Output is correct
13 Correct 61 ms 117688 KB Output is correct
14 Correct 62 ms 117580 KB Output is correct
15 Correct 63 ms 117700 KB Output is correct
16 Correct 61 ms 117688 KB Output is correct
17 Correct 59 ms 117704 KB Output is correct
18 Correct 64 ms 117696 KB Output is correct
19 Correct 61 ms 117680 KB Output is correct
20 Correct 69 ms 117692 KB Output is correct
21 Correct 62 ms 117692 KB Output is correct
22 Correct 59 ms 117592 KB Output is correct
23 Correct 61 ms 117700 KB Output is correct
24 Correct 61 ms 117616 KB Output is correct
25 Correct 59 ms 117580 KB Output is correct
26 Correct 59 ms 117656 KB Output is correct
27 Correct 63 ms 117616 KB Output is correct
28 Correct 63 ms 117712 KB Output is correct
29 Correct 70 ms 117696 KB Output is correct
30 Correct 61 ms 117660 KB Output is correct
31 Correct 62 ms 117640 KB Output is correct
32 Correct 60 ms 117720 KB Output is correct
33 Correct 66 ms 117716 KB Output is correct
34 Correct 64 ms 117736 KB Output is correct
35 Correct 67 ms 117592 KB Output is correct
36 Correct 59 ms 117688 KB Output is correct
37 Correct 66 ms 117708 KB Output is correct
38 Correct 59 ms 117708 KB Output is correct
39 Correct 60 ms 117644 KB Output is correct
40 Correct 68 ms 117720 KB Output is correct
41 Correct 61 ms 117632 KB Output is correct
42 Correct 58 ms 117656 KB Output is correct
43 Correct 59 ms 117676 KB Output is correct
44 Correct 61 ms 117600 KB Output is correct
45 Correct 59 ms 117712 KB Output is correct
46 Correct 58 ms 117696 KB Output is correct
47 Correct 59 ms 117704 KB Output is correct
48 Correct 62 ms 117696 KB Output is correct
49 Correct 61 ms 117592 KB Output is correct
50 Correct 65 ms 117864 KB Output is correct
51 Correct 58 ms 117756 KB Output is correct
52 Correct 60 ms 117772 KB Output is correct
53 Correct 58 ms 117744 KB Output is correct
54 Correct 64 ms 117704 KB Output is correct
55 Correct 62 ms 117792 KB Output is correct
56 Correct 62 ms 117788 KB Output is correct
57 Correct 61 ms 117704 KB Output is correct
58 Correct 58 ms 117628 KB Output is correct
59 Correct 62 ms 117688 KB Output is correct
60 Correct 62 ms 117676 KB Output is correct
61 Correct 61 ms 117748 KB Output is correct
62 Correct 60 ms 117712 KB Output is correct
63 Correct 62 ms 117612 KB Output is correct
64 Correct 62 ms 117580 KB Output is correct
65 Correct 65 ms 117708 KB Output is correct
66 Correct 59 ms 117580 KB Output is correct
67 Correct 61 ms 117768 KB Output is correct
68 Correct 59 ms 117676 KB Output is correct
69 Correct 61 ms 117640 KB Output is correct
70 Correct 60 ms 117728 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 117684 KB Output is correct
2 Correct 61 ms 117588 KB Output is correct
3 Correct 62 ms 117608 KB Output is correct
4 Correct 68 ms 117636 KB Output is correct
5 Correct 58 ms 117580 KB Output is correct
6 Correct 60 ms 117704 KB Output is correct
7 Correct 62 ms 117584 KB Output is correct
8 Correct 62 ms 117612 KB Output is correct
9 Correct 62 ms 117716 KB Output is correct
10 Correct 59 ms 117580 KB Output is correct
11 Correct 58 ms 117680 KB Output is correct
12 Correct 59 ms 117748 KB Output is correct
13 Correct 61 ms 117688 KB Output is correct
14 Correct 62 ms 117580 KB Output is correct
15 Correct 63 ms 117700 KB Output is correct
16 Correct 61 ms 117688 KB Output is correct
17 Correct 59 ms 117704 KB Output is correct
18 Correct 64 ms 117696 KB Output is correct
19 Correct 61 ms 117680 KB Output is correct
20 Correct 69 ms 117692 KB Output is correct
21 Correct 62 ms 117692 KB Output is correct
22 Correct 59 ms 117592 KB Output is correct
23 Correct 61 ms 117700 KB Output is correct
24 Correct 61 ms 117616 KB Output is correct
25 Correct 59 ms 117580 KB Output is correct
26 Correct 59 ms 117656 KB Output is correct
27 Correct 63 ms 117616 KB Output is correct
28 Correct 63 ms 117712 KB Output is correct
29 Correct 70 ms 117696 KB Output is correct
30 Correct 61 ms 117660 KB Output is correct
31 Correct 62 ms 117640 KB Output is correct
32 Correct 60 ms 117720 KB Output is correct
33 Correct 66 ms 117716 KB Output is correct
34 Correct 64 ms 117736 KB Output is correct
35 Correct 67 ms 117592 KB Output is correct
36 Correct 59 ms 117688 KB Output is correct
37 Correct 66 ms 117708 KB Output is correct
38 Correct 59 ms 117708 KB Output is correct
39 Correct 60 ms 117644 KB Output is correct
40 Correct 68 ms 117720 KB Output is correct
41 Correct 61 ms 117632 KB Output is correct
42 Correct 58 ms 117656 KB Output is correct
43 Correct 59 ms 117676 KB Output is correct
44 Correct 61 ms 117600 KB Output is correct
45 Correct 59 ms 117712 KB Output is correct
46 Correct 58 ms 117696 KB Output is correct
47 Correct 59 ms 117704 KB Output is correct
48 Correct 62 ms 117696 KB Output is correct
49 Correct 61 ms 117592 KB Output is correct
50 Correct 65 ms 117864 KB Output is correct
51 Correct 58 ms 117756 KB Output is correct
52 Correct 60 ms 117772 KB Output is correct
53 Correct 58 ms 117744 KB Output is correct
54 Correct 64 ms 117704 KB Output is correct
55 Correct 62 ms 117792 KB Output is correct
56 Correct 62 ms 117788 KB Output is correct
57 Correct 61 ms 117704 KB Output is correct
58 Correct 58 ms 117628 KB Output is correct
59 Correct 62 ms 117688 KB Output is correct
60 Correct 62 ms 117676 KB Output is correct
61 Correct 61 ms 117748 KB Output is correct
62 Correct 60 ms 117712 KB Output is correct
63 Correct 62 ms 117612 KB Output is correct
64 Correct 62 ms 117580 KB Output is correct
65 Correct 65 ms 117708 KB Output is correct
66 Correct 59 ms 117580 KB Output is correct
67 Correct 61 ms 117768 KB Output is correct
68 Correct 59 ms 117676 KB Output is correct
69 Correct 61 ms 117640 KB Output is correct
70 Correct 60 ms 117728 KB Output is correct
71 Correct 2727 ms 120412 KB Output is correct
72 Correct 1247 ms 119792 KB Output is correct
73 Correct 2527 ms 120392 KB Output is correct
74 Correct 809 ms 119556 KB Output is correct
75 Correct 1062 ms 119712 KB Output is correct
76 Execution timed out 5065 ms 120940 KB Time limit exceeded
77 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 62 ms 117684 KB Output is correct
2 Correct 61 ms 117588 KB Output is correct
3 Correct 62 ms 117608 KB Output is correct
4 Correct 68 ms 117636 KB Output is correct
5 Correct 58 ms 117580 KB Output is correct
6 Correct 60 ms 117704 KB Output is correct
7 Correct 62 ms 117584 KB Output is correct
8 Correct 62 ms 117612 KB Output is correct
9 Correct 62 ms 117716 KB Output is correct
10 Correct 59 ms 117580 KB Output is correct
11 Correct 58 ms 117680 KB Output is correct
12 Correct 59 ms 117748 KB Output is correct
13 Correct 61 ms 117688 KB Output is correct
14 Correct 62 ms 117580 KB Output is correct
15 Correct 63 ms 117700 KB Output is correct
16 Correct 61 ms 117688 KB Output is correct
17 Correct 59 ms 117704 KB Output is correct
18 Correct 64 ms 117696 KB Output is correct
19 Correct 61 ms 117680 KB Output is correct
20 Correct 69 ms 117692 KB Output is correct
21 Correct 62 ms 117692 KB Output is correct
22 Correct 59 ms 117592 KB Output is correct
23 Correct 61 ms 117700 KB Output is correct
24 Correct 61 ms 117616 KB Output is correct
25 Correct 59 ms 117580 KB Output is correct
26 Correct 59 ms 117656 KB Output is correct
27 Correct 63 ms 117616 KB Output is correct
28 Correct 63 ms 117712 KB Output is correct
29 Correct 70 ms 117696 KB Output is correct
30 Correct 61 ms 117660 KB Output is correct
31 Correct 62 ms 117640 KB Output is correct
32 Correct 60 ms 117720 KB Output is correct
33 Correct 66 ms 117716 KB Output is correct
34 Correct 64 ms 117736 KB Output is correct
35 Correct 67 ms 117592 KB Output is correct
36 Correct 59 ms 117688 KB Output is correct
37 Correct 66 ms 117708 KB Output is correct
38 Correct 59 ms 117708 KB Output is correct
39 Correct 60 ms 117644 KB Output is correct
40 Correct 68 ms 117720 KB Output is correct
41 Correct 61 ms 117632 KB Output is correct
42 Correct 58 ms 117656 KB Output is correct
43 Correct 59 ms 117676 KB Output is correct
44 Correct 61 ms 117600 KB Output is correct
45 Correct 59 ms 117712 KB Output is correct
46 Correct 58 ms 117696 KB Output is correct
47 Correct 59 ms 117704 KB Output is correct
48 Correct 62 ms 117696 KB Output is correct
49 Correct 61 ms 117592 KB Output is correct
50 Correct 65 ms 117864 KB Output is correct
51 Correct 58 ms 117756 KB Output is correct
52 Correct 60 ms 117772 KB Output is correct
53 Correct 58 ms 117744 KB Output is correct
54 Correct 64 ms 117704 KB Output is correct
55 Correct 62 ms 117792 KB Output is correct
56 Correct 62 ms 117788 KB Output is correct
57 Correct 61 ms 117704 KB Output is correct
58 Correct 58 ms 117628 KB Output is correct
59 Correct 62 ms 117688 KB Output is correct
60 Correct 62 ms 117676 KB Output is correct
61 Correct 61 ms 117748 KB Output is correct
62 Correct 60 ms 117712 KB Output is correct
63 Correct 62 ms 117612 KB Output is correct
64 Correct 62 ms 117580 KB Output is correct
65 Correct 65 ms 117708 KB Output is correct
66 Correct 59 ms 117580 KB Output is correct
67 Correct 61 ms 117768 KB Output is correct
68 Correct 59 ms 117676 KB Output is correct
69 Correct 61 ms 117640 KB Output is correct
70 Correct 60 ms 117728 KB Output is correct
71 Correct 2727 ms 120412 KB Output is correct
72 Correct 1247 ms 119792 KB Output is correct
73 Correct 2527 ms 120392 KB Output is correct
74 Correct 809 ms 119556 KB Output is correct
75 Correct 1062 ms 119712 KB Output is correct
76 Execution timed out 5065 ms 120940 KB Time limit exceeded
77 Halted 0 ms 0 KB -