답안 #822943

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
822943 2023-08-12T05:33:57 Z MohamedAhmed04 Toys (CEOI18_toy) C++14
100 / 100
943 ms 167640 KB
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 2004 ;

int n ;

vector<int>divi ;

vector<int>dp[MAX][MAX] ;
vector<int>Div[MAX] ;

vector<int>factorize(int x)
{
	vector<int>v ;
	for(int i = 1 ; i * i <= x ; ++i)
	{
		if(x%i == 0)
		{
			v.push_back(i) ;
			if(i*i != x)
				v.push_back(x/i) ;
		}
	}
	divi.push_back(1) ;
	sort(v.begin() , v.end()) ;
	return v ;
}

map<int , int>mp ;
vector<int>dp2[MAX] ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	vector<int>divi = factorize(n) ;
	int sz = divi.size() ;
	for(int i = 0 ; i < sz ; ++i)
	{
		Div[i] = factorize(divi[i]) ;
		mp[divi[i]] = i ;
	}
	for(int j = 0 ; j < sz ; ++j)
		dp[0][j] = {divi[j]-1} ;
	for(int i = 0 ; i < sz ; ++i)
	{
		dp[i][0] = {divi[i]-1} , dp2[i].push_back(divi[i]-1) ;
		for(int j = 1 ; j <= i ; ++j)
		{
			if(n % (1ll * divi[i] * divi[j]) != 0)
				continue ;
			for(auto &x : Div[i])
			{
				if(mp[x] >= j)
				{
					int idx = mp[divi[i] / x] , idx2 = mp[x] ;
					for(auto &k : dp[idx][idx2])
						dp[i][j].push_back(k) ;
				}
			}
			sort(dp[i][j].begin() , dp[i][j].end()) ;
			dp[i][j].erase(unique(dp[i][j].begin() , dp[i][j].end()) , dp[i][j].end()) ;
			int idx = mp[divi[i] * divi[j]] ;
			for(auto &x : dp[i][j])
				x += divi[j]-1 , dp2[idx].push_back(x) ;
		}
		sort(dp2[i].begin() , dp2[i].end()) ;
		dp2[i].erase(unique(dp2[i].begin() , dp2[i].end()) , dp2[i].end()) ;
	}
	cout<<dp2[sz-1].size()<<"\n" ;
	for(auto &x : dp2[sz-1])
		cout<<x<<" " ;
	cout<<"\n" ;
	return 0 ;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 94644 KB Output is correct
2 Correct 44 ms 94592 KB Output is correct
3 Correct 45 ms 94708 KB Output is correct
4 Correct 44 ms 94660 KB Output is correct
5 Correct 49 ms 94700 KB Output is correct
6 Correct 55 ms 94704 KB Output is correct
7 Correct 48 ms 94608 KB Output is correct
8 Correct 48 ms 94624 KB Output is correct
9 Correct 45 ms 94796 KB Output is correct
10 Correct 47 ms 94608 KB Output is correct
11 Correct 44 ms 94620 KB Output is correct
12 Correct 43 ms 94704 KB Output is correct
13 Correct 44 ms 94684 KB Output is correct
14 Correct 44 ms 94588 KB Output is correct
15 Correct 44 ms 94608 KB Output is correct
16 Correct 45 ms 94812 KB Output is correct
17 Correct 50 ms 94668 KB Output is correct
18 Correct 44 ms 94640 KB Output is correct
19 Correct 44 ms 94704 KB Output is correct
20 Correct 44 ms 94696 KB Output is correct
21 Correct 46 ms 94704 KB Output is correct
22 Correct 44 ms 94668 KB Output is correct
23 Correct 45 ms 94604 KB Output is correct
24 Correct 44 ms 94728 KB Output is correct
25 Correct 48 ms 94708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 94644 KB Output is correct
2 Correct 44 ms 94592 KB Output is correct
3 Correct 45 ms 94708 KB Output is correct
4 Correct 44 ms 94660 KB Output is correct
5 Correct 49 ms 94700 KB Output is correct
6 Correct 55 ms 94704 KB Output is correct
7 Correct 48 ms 94608 KB Output is correct
8 Correct 48 ms 94624 KB Output is correct
9 Correct 45 ms 94796 KB Output is correct
10 Correct 47 ms 94608 KB Output is correct
11 Correct 44 ms 94620 KB Output is correct
12 Correct 43 ms 94704 KB Output is correct
13 Correct 44 ms 94684 KB Output is correct
14 Correct 44 ms 94588 KB Output is correct
15 Correct 44 ms 94608 KB Output is correct
16 Correct 45 ms 94812 KB Output is correct
17 Correct 50 ms 94668 KB Output is correct
18 Correct 44 ms 94640 KB Output is correct
19 Correct 44 ms 94704 KB Output is correct
20 Correct 44 ms 94696 KB Output is correct
21 Correct 46 ms 94704 KB Output is correct
22 Correct 44 ms 94668 KB Output is correct
23 Correct 45 ms 94604 KB Output is correct
24 Correct 44 ms 94728 KB Output is correct
25 Correct 48 ms 94708 KB Output is correct
26 Correct 48 ms 94764 KB Output is correct
27 Correct 45 ms 94700 KB Output is correct
28 Correct 47 ms 94612 KB Output is correct
29 Correct 46 ms 94704 KB Output is correct
30 Correct 44 ms 94660 KB Output is correct
31 Correct 47 ms 94672 KB Output is correct
32 Correct 44 ms 94696 KB Output is correct
33 Correct 44 ms 94740 KB Output is correct
34 Correct 44 ms 94692 KB Output is correct
35 Correct 45 ms 94684 KB Output is correct
36 Correct 48 ms 94728 KB Output is correct
37 Correct 45 ms 94672 KB Output is correct
38 Correct 46 ms 94616 KB Output is correct
39 Correct 49 ms 94628 KB Output is correct
40 Correct 45 ms 94736 KB Output is correct
41 Correct 44 ms 94676 KB Output is correct
42 Correct 45 ms 94704 KB Output is correct
43 Correct 48 ms 94584 KB Output is correct
44 Correct 48 ms 94596 KB Output is correct
45 Correct 45 ms 94608 KB Output is correct
46 Correct 45 ms 94580 KB Output is correct
47 Correct 50 ms 94712 KB Output is correct
48 Correct 43 ms 94592 KB Output is correct
49 Correct 46 ms 94648 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 94644 KB Output is correct
2 Correct 44 ms 94592 KB Output is correct
3 Correct 45 ms 94708 KB Output is correct
4 Correct 44 ms 94660 KB Output is correct
5 Correct 49 ms 94700 KB Output is correct
6 Correct 55 ms 94704 KB Output is correct
7 Correct 48 ms 94608 KB Output is correct
8 Correct 48 ms 94624 KB Output is correct
9 Correct 45 ms 94796 KB Output is correct
10 Correct 47 ms 94608 KB Output is correct
11 Correct 44 ms 94620 KB Output is correct
12 Correct 43 ms 94704 KB Output is correct
13 Correct 44 ms 94684 KB Output is correct
14 Correct 44 ms 94588 KB Output is correct
15 Correct 44 ms 94608 KB Output is correct
16 Correct 45 ms 94812 KB Output is correct
17 Correct 50 ms 94668 KB Output is correct
18 Correct 44 ms 94640 KB Output is correct
19 Correct 44 ms 94704 KB Output is correct
20 Correct 44 ms 94696 KB Output is correct
21 Correct 46 ms 94704 KB Output is correct
22 Correct 44 ms 94668 KB Output is correct
23 Correct 45 ms 94604 KB Output is correct
24 Correct 44 ms 94728 KB Output is correct
25 Correct 48 ms 94708 KB Output is correct
26 Correct 48 ms 94764 KB Output is correct
27 Correct 45 ms 94700 KB Output is correct
28 Correct 47 ms 94612 KB Output is correct
29 Correct 46 ms 94704 KB Output is correct
30 Correct 44 ms 94660 KB Output is correct
31 Correct 47 ms 94672 KB Output is correct
32 Correct 44 ms 94696 KB Output is correct
33 Correct 44 ms 94740 KB Output is correct
34 Correct 44 ms 94692 KB Output is correct
35 Correct 45 ms 94684 KB Output is correct
36 Correct 48 ms 94728 KB Output is correct
37 Correct 45 ms 94672 KB Output is correct
38 Correct 46 ms 94616 KB Output is correct
39 Correct 49 ms 94628 KB Output is correct
40 Correct 45 ms 94736 KB Output is correct
41 Correct 44 ms 94676 KB Output is correct
42 Correct 45 ms 94704 KB Output is correct
43 Correct 48 ms 94584 KB Output is correct
44 Correct 48 ms 94596 KB Output is correct
45 Correct 45 ms 94608 KB Output is correct
46 Correct 45 ms 94580 KB Output is correct
47 Correct 50 ms 94712 KB Output is correct
48 Correct 43 ms 94592 KB Output is correct
49 Correct 46 ms 94648 KB Output is correct
50 Correct 45 ms 94848 KB Output is correct
51 Correct 46 ms 94804 KB Output is correct
52 Correct 44 ms 94868 KB Output is correct
53 Correct 44 ms 94832 KB Output is correct
54 Correct 44 ms 94792 KB Output is correct
55 Correct 49 ms 94844 KB Output is correct
56 Correct 46 ms 94916 KB Output is correct
57 Correct 52 ms 94844 KB Output is correct
58 Correct 45 ms 94688 KB Output is correct
59 Correct 43 ms 94672 KB Output is correct
60 Correct 43 ms 94704 KB Output is correct
61 Correct 45 ms 94704 KB Output is correct
62 Correct 47 ms 94716 KB Output is correct
63 Correct 44 ms 94716 KB Output is correct
64 Correct 44 ms 94708 KB Output is correct
65 Correct 45 ms 94680 KB Output is correct
66 Correct 48 ms 94644 KB Output is correct
67 Correct 45 ms 94716 KB Output is correct
68 Correct 43 ms 94700 KB Output is correct
69 Correct 45 ms 94724 KB Output is correct
70 Correct 44 ms 94652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 94644 KB Output is correct
2 Correct 44 ms 94592 KB Output is correct
3 Correct 45 ms 94708 KB Output is correct
4 Correct 44 ms 94660 KB Output is correct
5 Correct 49 ms 94700 KB Output is correct
6 Correct 55 ms 94704 KB Output is correct
7 Correct 48 ms 94608 KB Output is correct
8 Correct 48 ms 94624 KB Output is correct
9 Correct 45 ms 94796 KB Output is correct
10 Correct 47 ms 94608 KB Output is correct
11 Correct 44 ms 94620 KB Output is correct
12 Correct 43 ms 94704 KB Output is correct
13 Correct 44 ms 94684 KB Output is correct
14 Correct 44 ms 94588 KB Output is correct
15 Correct 44 ms 94608 KB Output is correct
16 Correct 45 ms 94812 KB Output is correct
17 Correct 50 ms 94668 KB Output is correct
18 Correct 44 ms 94640 KB Output is correct
19 Correct 44 ms 94704 KB Output is correct
20 Correct 44 ms 94696 KB Output is correct
21 Correct 46 ms 94704 KB Output is correct
22 Correct 44 ms 94668 KB Output is correct
23 Correct 45 ms 94604 KB Output is correct
24 Correct 44 ms 94728 KB Output is correct
25 Correct 48 ms 94708 KB Output is correct
26 Correct 48 ms 94764 KB Output is correct
27 Correct 45 ms 94700 KB Output is correct
28 Correct 47 ms 94612 KB Output is correct
29 Correct 46 ms 94704 KB Output is correct
30 Correct 44 ms 94660 KB Output is correct
31 Correct 47 ms 94672 KB Output is correct
32 Correct 44 ms 94696 KB Output is correct
33 Correct 44 ms 94740 KB Output is correct
34 Correct 44 ms 94692 KB Output is correct
35 Correct 45 ms 94684 KB Output is correct
36 Correct 48 ms 94728 KB Output is correct
37 Correct 45 ms 94672 KB Output is correct
38 Correct 46 ms 94616 KB Output is correct
39 Correct 49 ms 94628 KB Output is correct
40 Correct 45 ms 94736 KB Output is correct
41 Correct 44 ms 94676 KB Output is correct
42 Correct 45 ms 94704 KB Output is correct
43 Correct 48 ms 94584 KB Output is correct
44 Correct 48 ms 94596 KB Output is correct
45 Correct 45 ms 94608 KB Output is correct
46 Correct 45 ms 94580 KB Output is correct
47 Correct 50 ms 94712 KB Output is correct
48 Correct 43 ms 94592 KB Output is correct
49 Correct 46 ms 94648 KB Output is correct
50 Correct 45 ms 94848 KB Output is correct
51 Correct 46 ms 94804 KB Output is correct
52 Correct 44 ms 94868 KB Output is correct
53 Correct 44 ms 94832 KB Output is correct
54 Correct 44 ms 94792 KB Output is correct
55 Correct 49 ms 94844 KB Output is correct
56 Correct 46 ms 94916 KB Output is correct
57 Correct 52 ms 94844 KB Output is correct
58 Correct 45 ms 94688 KB Output is correct
59 Correct 43 ms 94672 KB Output is correct
60 Correct 43 ms 94704 KB Output is correct
61 Correct 45 ms 94704 KB Output is correct
62 Correct 47 ms 94716 KB Output is correct
63 Correct 44 ms 94716 KB Output is correct
64 Correct 44 ms 94708 KB Output is correct
65 Correct 45 ms 94680 KB Output is correct
66 Correct 48 ms 94644 KB Output is correct
67 Correct 45 ms 94716 KB Output is correct
68 Correct 43 ms 94700 KB Output is correct
69 Correct 45 ms 94724 KB Output is correct
70 Correct 44 ms 94652 KB Output is correct
71 Correct 186 ms 106508 KB Output is correct
72 Correct 146 ms 102784 KB Output is correct
73 Correct 170 ms 106088 KB Output is correct
74 Correct 113 ms 101116 KB Output is correct
75 Correct 130 ms 102392 KB Output is correct
76 Correct 232 ms 112960 KB Output is correct
77 Correct 261 ms 111904 KB Output is correct
78 Correct 207 ms 109312 KB Output is correct
79 Correct 186 ms 109024 KB Output is correct
80 Correct 46 ms 94680 KB Output is correct
81 Correct 44 ms 94700 KB Output is correct
82 Correct 48 ms 94808 KB Output is correct
83 Correct 61 ms 96492 KB Output is correct
84 Correct 69 ms 97224 KB Output is correct
85 Correct 50 ms 95128 KB Output is correct
86 Correct 46 ms 94676 KB Output is correct
87 Correct 67 ms 97148 KB Output is correct
88 Correct 45 ms 94624 KB Output is correct
89 Correct 45 ms 94580 KB Output is correct
90 Correct 45 ms 94708 KB Output is correct
91 Correct 52 ms 95336 KB Output is correct
92 Correct 83 ms 97720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 47 ms 94644 KB Output is correct
2 Correct 44 ms 94592 KB Output is correct
3 Correct 45 ms 94708 KB Output is correct
4 Correct 44 ms 94660 KB Output is correct
5 Correct 49 ms 94700 KB Output is correct
6 Correct 55 ms 94704 KB Output is correct
7 Correct 48 ms 94608 KB Output is correct
8 Correct 48 ms 94624 KB Output is correct
9 Correct 45 ms 94796 KB Output is correct
10 Correct 47 ms 94608 KB Output is correct
11 Correct 44 ms 94620 KB Output is correct
12 Correct 43 ms 94704 KB Output is correct
13 Correct 44 ms 94684 KB Output is correct
14 Correct 44 ms 94588 KB Output is correct
15 Correct 44 ms 94608 KB Output is correct
16 Correct 45 ms 94812 KB Output is correct
17 Correct 50 ms 94668 KB Output is correct
18 Correct 44 ms 94640 KB Output is correct
19 Correct 44 ms 94704 KB Output is correct
20 Correct 44 ms 94696 KB Output is correct
21 Correct 46 ms 94704 KB Output is correct
22 Correct 44 ms 94668 KB Output is correct
23 Correct 45 ms 94604 KB Output is correct
24 Correct 44 ms 94728 KB Output is correct
25 Correct 48 ms 94708 KB Output is correct
26 Correct 48 ms 94764 KB Output is correct
27 Correct 45 ms 94700 KB Output is correct
28 Correct 47 ms 94612 KB Output is correct
29 Correct 46 ms 94704 KB Output is correct
30 Correct 44 ms 94660 KB Output is correct
31 Correct 47 ms 94672 KB Output is correct
32 Correct 44 ms 94696 KB Output is correct
33 Correct 44 ms 94740 KB Output is correct
34 Correct 44 ms 94692 KB Output is correct
35 Correct 45 ms 94684 KB Output is correct
36 Correct 48 ms 94728 KB Output is correct
37 Correct 45 ms 94672 KB Output is correct
38 Correct 46 ms 94616 KB Output is correct
39 Correct 49 ms 94628 KB Output is correct
40 Correct 45 ms 94736 KB Output is correct
41 Correct 44 ms 94676 KB Output is correct
42 Correct 45 ms 94704 KB Output is correct
43 Correct 48 ms 94584 KB Output is correct
44 Correct 48 ms 94596 KB Output is correct
45 Correct 45 ms 94608 KB Output is correct
46 Correct 45 ms 94580 KB Output is correct
47 Correct 50 ms 94712 KB Output is correct
48 Correct 43 ms 94592 KB Output is correct
49 Correct 46 ms 94648 KB Output is correct
50 Correct 45 ms 94848 KB Output is correct
51 Correct 46 ms 94804 KB Output is correct
52 Correct 44 ms 94868 KB Output is correct
53 Correct 44 ms 94832 KB Output is correct
54 Correct 44 ms 94792 KB Output is correct
55 Correct 49 ms 94844 KB Output is correct
56 Correct 46 ms 94916 KB Output is correct
57 Correct 52 ms 94844 KB Output is correct
58 Correct 45 ms 94688 KB Output is correct
59 Correct 43 ms 94672 KB Output is correct
60 Correct 43 ms 94704 KB Output is correct
61 Correct 45 ms 94704 KB Output is correct
62 Correct 47 ms 94716 KB Output is correct
63 Correct 44 ms 94716 KB Output is correct
64 Correct 44 ms 94708 KB Output is correct
65 Correct 45 ms 94680 KB Output is correct
66 Correct 48 ms 94644 KB Output is correct
67 Correct 45 ms 94716 KB Output is correct
68 Correct 43 ms 94700 KB Output is correct
69 Correct 45 ms 94724 KB Output is correct
70 Correct 44 ms 94652 KB Output is correct
71 Correct 186 ms 106508 KB Output is correct
72 Correct 146 ms 102784 KB Output is correct
73 Correct 170 ms 106088 KB Output is correct
74 Correct 113 ms 101116 KB Output is correct
75 Correct 130 ms 102392 KB Output is correct
76 Correct 232 ms 112960 KB Output is correct
77 Correct 261 ms 111904 KB Output is correct
78 Correct 207 ms 109312 KB Output is correct
79 Correct 186 ms 109024 KB Output is correct
80 Correct 46 ms 94680 KB Output is correct
81 Correct 44 ms 94700 KB Output is correct
82 Correct 48 ms 94808 KB Output is correct
83 Correct 61 ms 96492 KB Output is correct
84 Correct 69 ms 97224 KB Output is correct
85 Correct 50 ms 95128 KB Output is correct
86 Correct 46 ms 94676 KB Output is correct
87 Correct 67 ms 97148 KB Output is correct
88 Correct 45 ms 94624 KB Output is correct
89 Correct 45 ms 94580 KB Output is correct
90 Correct 45 ms 94708 KB Output is correct
91 Correct 52 ms 95336 KB Output is correct
92 Correct 83 ms 97720 KB Output is correct
93 Correct 710 ms 153576 KB Output is correct
94 Correct 429 ms 126868 KB Output is correct
95 Correct 502 ms 132752 KB Output is correct
96 Correct 429 ms 129000 KB Output is correct
97 Correct 392 ms 126228 KB Output is correct
98 Correct 773 ms 160696 KB Output is correct
99 Correct 943 ms 167640 KB Output is correct
100 Correct 774 ms 159876 KB Output is correct
101 Correct 714 ms 158252 KB Output is correct
102 Correct 605 ms 150836 KB Output is correct
103 Correct 523 ms 137660 KB Output is correct
104 Correct 49 ms 94704 KB Output is correct
105 Correct 45 ms 94652 KB Output is correct
106 Correct 46 ms 94952 KB Output is correct
107 Correct 94 ms 100108 KB Output is correct
108 Correct 165 ms 107996 KB Output is correct
109 Correct 58 ms 95932 KB Output is correct
110 Correct 45 ms 94584 KB Output is correct
111 Correct 113 ms 101036 KB Output is correct
112 Correct 45 ms 94588 KB Output is correct
113 Correct 51 ms 94644 KB Output is correct
114 Correct 64 ms 94988 KB Output is correct
115 Correct 55 ms 94604 KB Output is correct
116 Correct 54 ms 95208 KB Output is correct
117 Correct 191 ms 105964 KB Output is correct