답안 #406350

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
406350 2021-05-17T12:43:40 Z abdzag Toys (CEOI18_toy) C++17
100 / 100
935 ms 60484 KB
#include<bits/stdc++.h>
#include<unordered_map>
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define all(v) v.begin(),v.end()
#define trav(a,v) for(auto&a:v)
#define  sz(a) a.size()
typedef long double ld;
using namespace std;
const long long inf = 1e15;
typedef long long ll;
typedef unsigned long long ull;
struct Deleter
{
	void operator () (int* ptr)
	{
		delete ptr;
	}
};
int main() {
	cin.sync_with_stdio(false);
	vector<int> primes;
	primes.push_back(2);
	rep(i, 3, 4e4) {
		ll val = sqrt(i);
		bool done = true;
		rep(j, 0, primes.size()) {
			if (i % primes[j] == 0) {
				done = false;
				break;
			}
			if (primes[j] * primes[j] > i)break;
		}
		if (done) {
			primes.push_back(i);
		}
	}
	ll n;
	cin >> n;
	ll cur = n;
	if (n == 1){
		cout <<1<<endl<< 0 << endl;
	return 0;
}
	vector<int> v;
	rep(i, 0, primes.size()) {
		if (cur % primes[i] == 0) {
			v.push_back(primes[i]);
			cur /= primes[i];
			i--;
		}
	}
	ll last = 1;
	if (cur != 1) {
		v.push_back(cur);
	}
	else {
		last = v.back();
		v.pop_back();
	}
	set<vector<int>> dp;
	set<vector<int>> dp0;
	vector<int> vv;
	dp0.insert(vv);
	trav(fac, v) {
		trav(vec, dp0) {
			rep(i, 0, vec.size()) {
				vector<int> next = vec;
				next[i] *= fac;
				sort(all(next));
				dp.insert(next);
			}

			vector<int> next = vec;
			next.push_back(fac);
			sort(all(next));
			dp.insert(next);
		}
		dp.swap(dp0);
		dp.clear();
	}
	set<int> ans;
	trav(vec, dp0) {
		ll val = 0;
		ll val0 = 0;
		vector<int> ny = vec;
		ny.push_back(1);
		trav(a, vec) {
			val += a - 1;
		}
		val0 = val;
		trav(a, ny) {
			val += (last - 1) * a;
			ans.insert(val);
			val = val0;
		}

	}
	cout << ans.size() << endl;
	trav(a, ans)cout << a << " ";
	return 0;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:25:6: warning: unused variable 'val' [-Wunused-variable]
   25 |   ll val = sqrt(i);
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 320 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 3 ms 360 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
8 Correct 3 ms 364 KB Output is correct
9 Correct 3 ms 332 KB Output is correct
10 Correct 3 ms 368 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 3 ms 368 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 3 ms 332 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 3 ms 364 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
21 Correct 3 ms 332 KB Output is correct
22 Correct 3 ms 332 KB Output is correct
23 Correct 3 ms 368 KB Output is correct
24 Correct 3 ms 332 KB Output is correct
25 Correct 3 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 320 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 3 ms 360 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
8 Correct 3 ms 364 KB Output is correct
9 Correct 3 ms 332 KB Output is correct
10 Correct 3 ms 368 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 3 ms 368 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 3 ms 332 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 3 ms 364 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
21 Correct 3 ms 332 KB Output is correct
22 Correct 3 ms 332 KB Output is correct
23 Correct 3 ms 368 KB Output is correct
24 Correct 3 ms 332 KB Output is correct
25 Correct 3 ms 332 KB Output is correct
26 Correct 3 ms 372 KB Output is correct
27 Correct 3 ms 332 KB Output is correct
28 Correct 3 ms 332 KB Output is correct
29 Correct 3 ms 360 KB Output is correct
30 Correct 3 ms 332 KB Output is correct
31 Correct 3 ms 332 KB Output is correct
32 Correct 3 ms 332 KB Output is correct
33 Correct 3 ms 332 KB Output is correct
34 Correct 3 ms 360 KB Output is correct
35 Correct 3 ms 332 KB Output is correct
36 Correct 3 ms 332 KB Output is correct
37 Correct 3 ms 332 KB Output is correct
38 Correct 3 ms 332 KB Output is correct
39 Correct 3 ms 332 KB Output is correct
40 Correct 3 ms 364 KB Output is correct
41 Correct 3 ms 360 KB Output is correct
42 Correct 3 ms 364 KB Output is correct
43 Correct 3 ms 364 KB Output is correct
44 Correct 3 ms 332 KB Output is correct
45 Correct 3 ms 332 KB Output is correct
46 Correct 3 ms 332 KB Output is correct
47 Correct 3 ms 332 KB Output is correct
48 Correct 3 ms 332 KB Output is correct
49 Correct 3 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 320 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 3 ms 360 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
8 Correct 3 ms 364 KB Output is correct
9 Correct 3 ms 332 KB Output is correct
10 Correct 3 ms 368 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 3 ms 368 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 3 ms 332 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 3 ms 364 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
21 Correct 3 ms 332 KB Output is correct
22 Correct 3 ms 332 KB Output is correct
23 Correct 3 ms 368 KB Output is correct
24 Correct 3 ms 332 KB Output is correct
25 Correct 3 ms 332 KB Output is correct
26 Correct 3 ms 372 KB Output is correct
27 Correct 3 ms 332 KB Output is correct
28 Correct 3 ms 332 KB Output is correct
29 Correct 3 ms 360 KB Output is correct
30 Correct 3 ms 332 KB Output is correct
31 Correct 3 ms 332 KB Output is correct
32 Correct 3 ms 332 KB Output is correct
33 Correct 3 ms 332 KB Output is correct
34 Correct 3 ms 360 KB Output is correct
35 Correct 3 ms 332 KB Output is correct
36 Correct 3 ms 332 KB Output is correct
37 Correct 3 ms 332 KB Output is correct
38 Correct 3 ms 332 KB Output is correct
39 Correct 3 ms 332 KB Output is correct
40 Correct 3 ms 364 KB Output is correct
41 Correct 3 ms 360 KB Output is correct
42 Correct 3 ms 364 KB Output is correct
43 Correct 3 ms 364 KB Output is correct
44 Correct 3 ms 332 KB Output is correct
45 Correct 3 ms 332 KB Output is correct
46 Correct 3 ms 332 KB Output is correct
47 Correct 3 ms 332 KB Output is correct
48 Correct 3 ms 332 KB Output is correct
49 Correct 3 ms 332 KB Output is correct
50 Correct 3 ms 332 KB Output is correct
51 Correct 4 ms 332 KB Output is correct
52 Correct 3 ms 332 KB Output is correct
53 Correct 4 ms 336 KB Output is correct
54 Correct 3 ms 368 KB Output is correct
55 Correct 4 ms 460 KB Output is correct
56 Correct 4 ms 332 KB Output is correct
57 Correct 4 ms 332 KB Output is correct
58 Correct 3 ms 360 KB Output is correct
59 Correct 3 ms 332 KB Output is correct
60 Correct 4 ms 332 KB Output is correct
61 Correct 5 ms 460 KB Output is correct
62 Correct 3 ms 460 KB Output is correct
63 Correct 3 ms 332 KB Output is correct
64 Correct 3 ms 332 KB Output is correct
65 Correct 4 ms 332 KB Output is correct
66 Correct 3 ms 368 KB Output is correct
67 Correct 3 ms 340 KB Output is correct
68 Correct 3 ms 332 KB Output is correct
69 Correct 13 ms 344 KB Output is correct
70 Correct 3 ms 368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 320 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 3 ms 360 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
8 Correct 3 ms 364 KB Output is correct
9 Correct 3 ms 332 KB Output is correct
10 Correct 3 ms 368 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 3 ms 368 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 3 ms 332 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 3 ms 364 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
21 Correct 3 ms 332 KB Output is correct
22 Correct 3 ms 332 KB Output is correct
23 Correct 3 ms 368 KB Output is correct
24 Correct 3 ms 332 KB Output is correct
25 Correct 3 ms 332 KB Output is correct
26 Correct 3 ms 372 KB Output is correct
27 Correct 3 ms 332 KB Output is correct
28 Correct 3 ms 332 KB Output is correct
29 Correct 3 ms 360 KB Output is correct
30 Correct 3 ms 332 KB Output is correct
31 Correct 3 ms 332 KB Output is correct
32 Correct 3 ms 332 KB Output is correct
33 Correct 3 ms 332 KB Output is correct
34 Correct 3 ms 360 KB Output is correct
35 Correct 3 ms 332 KB Output is correct
36 Correct 3 ms 332 KB Output is correct
37 Correct 3 ms 332 KB Output is correct
38 Correct 3 ms 332 KB Output is correct
39 Correct 3 ms 332 KB Output is correct
40 Correct 3 ms 364 KB Output is correct
41 Correct 3 ms 360 KB Output is correct
42 Correct 3 ms 364 KB Output is correct
43 Correct 3 ms 364 KB Output is correct
44 Correct 3 ms 332 KB Output is correct
45 Correct 3 ms 332 KB Output is correct
46 Correct 3 ms 332 KB Output is correct
47 Correct 3 ms 332 KB Output is correct
48 Correct 3 ms 332 KB Output is correct
49 Correct 3 ms 332 KB Output is correct
50 Correct 3 ms 332 KB Output is correct
51 Correct 4 ms 332 KB Output is correct
52 Correct 3 ms 332 KB Output is correct
53 Correct 4 ms 336 KB Output is correct
54 Correct 3 ms 368 KB Output is correct
55 Correct 4 ms 460 KB Output is correct
56 Correct 4 ms 332 KB Output is correct
57 Correct 4 ms 332 KB Output is correct
58 Correct 3 ms 360 KB Output is correct
59 Correct 3 ms 332 KB Output is correct
60 Correct 4 ms 332 KB Output is correct
61 Correct 5 ms 460 KB Output is correct
62 Correct 3 ms 460 KB Output is correct
63 Correct 3 ms 332 KB Output is correct
64 Correct 3 ms 332 KB Output is correct
65 Correct 4 ms 332 KB Output is correct
66 Correct 3 ms 368 KB Output is correct
67 Correct 3 ms 340 KB Output is correct
68 Correct 3 ms 332 KB Output is correct
69 Correct 13 ms 344 KB Output is correct
70 Correct 3 ms 368 KB Output is correct
71 Correct 66 ms 5804 KB Output is correct
72 Correct 45 ms 4000 KB Output is correct
73 Correct 80 ms 6724 KB Output is correct
74 Correct 31 ms 3220 KB Output is correct
75 Correct 42 ms 4092 KB Output is correct
76 Correct 145 ms 12136 KB Output is correct
77 Correct 184 ms 14480 KB Output is correct
78 Correct 141 ms 9360 KB Output is correct
79 Correct 117 ms 9796 KB Output is correct
80 Correct 3 ms 332 KB Output is correct
81 Correct 3 ms 332 KB Output is correct
82 Correct 21 ms 744 KB Output is correct
83 Correct 152 ms 6388 KB Output is correct
84 Correct 60 ms 4340 KB Output is correct
85 Correct 19 ms 1084 KB Output is correct
86 Correct 3 ms 332 KB Output is correct
87 Correct 93 ms 4912 KB Output is correct
88 Correct 3 ms 332 KB Output is correct
89 Correct 3 ms 332 KB Output is correct
90 Correct 3 ms 348 KB Output is correct
91 Correct 6 ms 744 KB Output is correct
92 Correct 14 ms 1612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 332 KB Output is correct
2 Correct 4 ms 320 KB Output is correct
3 Correct 3 ms 332 KB Output is correct
4 Correct 3 ms 332 KB Output is correct
5 Correct 3 ms 332 KB Output is correct
6 Correct 3 ms 360 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
8 Correct 3 ms 364 KB Output is correct
9 Correct 3 ms 332 KB Output is correct
10 Correct 3 ms 368 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 3 ms 368 KB Output is correct
13 Correct 3 ms 332 KB Output is correct
14 Correct 3 ms 332 KB Output is correct
15 Correct 3 ms 340 KB Output is correct
16 Correct 3 ms 364 KB Output is correct
17 Correct 3 ms 364 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 3 ms 364 KB Output is correct
20 Correct 3 ms 332 KB Output is correct
21 Correct 3 ms 332 KB Output is correct
22 Correct 3 ms 332 KB Output is correct
23 Correct 3 ms 368 KB Output is correct
24 Correct 3 ms 332 KB Output is correct
25 Correct 3 ms 332 KB Output is correct
26 Correct 3 ms 372 KB Output is correct
27 Correct 3 ms 332 KB Output is correct
28 Correct 3 ms 332 KB Output is correct
29 Correct 3 ms 360 KB Output is correct
30 Correct 3 ms 332 KB Output is correct
31 Correct 3 ms 332 KB Output is correct
32 Correct 3 ms 332 KB Output is correct
33 Correct 3 ms 332 KB Output is correct
34 Correct 3 ms 360 KB Output is correct
35 Correct 3 ms 332 KB Output is correct
36 Correct 3 ms 332 KB Output is correct
37 Correct 3 ms 332 KB Output is correct
38 Correct 3 ms 332 KB Output is correct
39 Correct 3 ms 332 KB Output is correct
40 Correct 3 ms 364 KB Output is correct
41 Correct 3 ms 360 KB Output is correct
42 Correct 3 ms 364 KB Output is correct
43 Correct 3 ms 364 KB Output is correct
44 Correct 3 ms 332 KB Output is correct
45 Correct 3 ms 332 KB Output is correct
46 Correct 3 ms 332 KB Output is correct
47 Correct 3 ms 332 KB Output is correct
48 Correct 3 ms 332 KB Output is correct
49 Correct 3 ms 332 KB Output is correct
50 Correct 3 ms 332 KB Output is correct
51 Correct 4 ms 332 KB Output is correct
52 Correct 3 ms 332 KB Output is correct
53 Correct 4 ms 336 KB Output is correct
54 Correct 3 ms 368 KB Output is correct
55 Correct 4 ms 460 KB Output is correct
56 Correct 4 ms 332 KB Output is correct
57 Correct 4 ms 332 KB Output is correct
58 Correct 3 ms 360 KB Output is correct
59 Correct 3 ms 332 KB Output is correct
60 Correct 4 ms 332 KB Output is correct
61 Correct 5 ms 460 KB Output is correct
62 Correct 3 ms 460 KB Output is correct
63 Correct 3 ms 332 KB Output is correct
64 Correct 3 ms 332 KB Output is correct
65 Correct 4 ms 332 KB Output is correct
66 Correct 3 ms 368 KB Output is correct
67 Correct 3 ms 340 KB Output is correct
68 Correct 3 ms 332 KB Output is correct
69 Correct 13 ms 344 KB Output is correct
70 Correct 3 ms 368 KB Output is correct
71 Correct 66 ms 5804 KB Output is correct
72 Correct 45 ms 4000 KB Output is correct
73 Correct 80 ms 6724 KB Output is correct
74 Correct 31 ms 3220 KB Output is correct
75 Correct 42 ms 4092 KB Output is correct
76 Correct 145 ms 12136 KB Output is correct
77 Correct 184 ms 14480 KB Output is correct
78 Correct 141 ms 9360 KB Output is correct
79 Correct 117 ms 9796 KB Output is correct
80 Correct 3 ms 332 KB Output is correct
81 Correct 3 ms 332 KB Output is correct
82 Correct 21 ms 744 KB Output is correct
83 Correct 152 ms 6388 KB Output is correct
84 Correct 60 ms 4340 KB Output is correct
85 Correct 19 ms 1084 KB Output is correct
86 Correct 3 ms 332 KB Output is correct
87 Correct 93 ms 4912 KB Output is correct
88 Correct 3 ms 332 KB Output is correct
89 Correct 3 ms 332 KB Output is correct
90 Correct 3 ms 348 KB Output is correct
91 Correct 6 ms 744 KB Output is correct
92 Correct 14 ms 1612 KB Output is correct
93 Correct 547 ms 38184 KB Output is correct
94 Correct 244 ms 15532 KB Output is correct
95 Correct 281 ms 21856 KB Output is correct
96 Correct 255 ms 19412 KB Output is correct
97 Correct 253 ms 19416 KB Output is correct
98 Correct 674 ms 46788 KB Output is correct
99 Correct 848 ms 57100 KB Output is correct
100 Correct 695 ms 46828 KB Output is correct
101 Correct 935 ms 60484 KB Output is correct
102 Correct 753 ms 51012 KB Output is correct
103 Correct 359 ms 25364 KB Output is correct
104 Correct 3 ms 332 KB Output is correct
105 Correct 3 ms 332 KB Output is correct
106 Correct 48 ms 1064 KB Output is correct
107 Correct 854 ms 25720 KB Output is correct
108 Correct 702 ms 35384 KB Output is correct
109 Correct 53 ms 2636 KB Output is correct
110 Correct 3 ms 340 KB Output is correct
111 Correct 333 ms 15320 KB Output is correct
112 Correct 3 ms 340 KB Output is correct
113 Correct 3 ms 332 KB Output is correct
114 Correct 4 ms 460 KB Output is correct
115 Correct 3 ms 332 KB Output is correct
116 Correct 6 ms 716 KB Output is correct
117 Correct 59 ms 5356 KB Output is correct