답안 #457886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
457886 2021-08-07T13:20:30 Z hhhhaura Toys (CEOI18_toy) C++14
100 / 100
1641 ms 34848 KB
#define wiwihorz
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)
#include <bits/stdc++.h>

#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))

#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)

using namespace std;

#define int long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())

#ifdef wiwihorz
#define print(a...) cerr << "Line " << __LINE__ <<": ", kout("[" + string(#a) + "] = ", a)
void kout() {cerr << endl;}
void vprint(auto L, auto R) { cerr << *L << " \n"[next(L) == R], ++L;}
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); }
#else
#define print(...) 0
#define vprint(...) 0
#endif
namespace solver {
	vector<int> ans;
	vector<vector<int>> v(10000, vector<int>());
	map<int, int> mp;
	int ii = 0;
	void solve(int n, int sum, int big) {
		if(n == 1) {
			ans.push_back(sum);
			return;
		}
		if(mp.find(n) == mp.end()) {
			mp[n] = ++ii;
			for(int i = 2; i * i <= n; i ++) {
				if(n % i) continue;
				v[ii].push_back(i);
				v[ii].push_back(n/ i);
			}
			v[ii].push_back(n);
		}
		int id = mp[n];
		for(auto i : v[id]) 
			if(i >= big) solve(n / i, sum + i - 1, i);
		return;
	}
};
using namespace solver;
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n; 
	cin >> n;
	solve(n, 0, 0);
	sort(all(ans));
	ans.resize(unique(all(ans)) - ans.begin());
	cout << ans.size() << "\n";
	rep(i, 0, signed(ans.size()) - 1) {
		cout << ans[i] << " \n"[i + 1 == ans.size()];
	}
	return 0;
}

Compilation message

toy.cpp:3: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    3 | #pragma loop-opt(on)
      | 
toy.cpp:25:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   25 | void vprint(auto L, auto R) { cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
toy.cpp:25:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   25 | void vprint(auto L, auto R) { cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
toy.cpp: In function 'int main()':
toy.cpp:66:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |   cout << ans[i] << " \n"[i + 1 == ans.size()];
      |                           ~~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 1 ms 460 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
33 Correct 1 ms 460 KB Output is correct
34 Correct 1 ms 460 KB Output is correct
35 Correct 1 ms 460 KB Output is correct
36 Correct 1 ms 460 KB Output is correct
37 Correct 1 ms 460 KB Output is correct
38 Correct 1 ms 460 KB Output is correct
39 Correct 1 ms 460 KB Output is correct
40 Correct 1 ms 460 KB Output is correct
41 Correct 1 ms 460 KB Output is correct
42 Correct 1 ms 460 KB Output is correct
43 Correct 1 ms 460 KB Output is correct
44 Correct 1 ms 460 KB Output is correct
45 Correct 1 ms 460 KB Output is correct
46 Correct 1 ms 460 KB Output is correct
47 Correct 1 ms 460 KB Output is correct
48 Correct 1 ms 460 KB Output is correct
49 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 1 ms 460 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
33 Correct 1 ms 460 KB Output is correct
34 Correct 1 ms 460 KB Output is correct
35 Correct 1 ms 460 KB Output is correct
36 Correct 1 ms 460 KB Output is correct
37 Correct 1 ms 460 KB Output is correct
38 Correct 1 ms 460 KB Output is correct
39 Correct 1 ms 460 KB Output is correct
40 Correct 1 ms 460 KB Output is correct
41 Correct 1 ms 460 KB Output is correct
42 Correct 1 ms 460 KB Output is correct
43 Correct 1 ms 460 KB Output is correct
44 Correct 1 ms 460 KB Output is correct
45 Correct 1 ms 460 KB Output is correct
46 Correct 1 ms 460 KB Output is correct
47 Correct 1 ms 460 KB Output is correct
48 Correct 1 ms 460 KB Output is correct
49 Correct 1 ms 460 KB Output is correct
50 Correct 2 ms 588 KB Output is correct
51 Correct 1 ms 588 KB Output is correct
52 Correct 1 ms 588 KB Output is correct
53 Correct 1 ms 588 KB Output is correct
54 Correct 1 ms 588 KB Output is correct
55 Correct 2 ms 588 KB Output is correct
56 Correct 2 ms 588 KB Output is correct
57 Correct 2 ms 584 KB Output is correct
58 Correct 1 ms 460 KB Output is correct
59 Correct 1 ms 460 KB Output is correct
60 Correct 1 ms 460 KB Output is correct
61 Correct 1 ms 588 KB Output is correct
62 Correct 1 ms 460 KB Output is correct
63 Correct 1 ms 460 KB Output is correct
64 Correct 1 ms 460 KB Output is correct
65 Correct 1 ms 588 KB Output is correct
66 Correct 1 ms 460 KB Output is correct
67 Correct 1 ms 460 KB Output is correct
68 Correct 1 ms 460 KB Output is correct
69 Correct 1 ms 460 KB Output is correct
70 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 1 ms 460 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
33 Correct 1 ms 460 KB Output is correct
34 Correct 1 ms 460 KB Output is correct
35 Correct 1 ms 460 KB Output is correct
36 Correct 1 ms 460 KB Output is correct
37 Correct 1 ms 460 KB Output is correct
38 Correct 1 ms 460 KB Output is correct
39 Correct 1 ms 460 KB Output is correct
40 Correct 1 ms 460 KB Output is correct
41 Correct 1 ms 460 KB Output is correct
42 Correct 1 ms 460 KB Output is correct
43 Correct 1 ms 460 KB Output is correct
44 Correct 1 ms 460 KB Output is correct
45 Correct 1 ms 460 KB Output is correct
46 Correct 1 ms 460 KB Output is correct
47 Correct 1 ms 460 KB Output is correct
48 Correct 1 ms 460 KB Output is correct
49 Correct 1 ms 460 KB Output is correct
50 Correct 2 ms 588 KB Output is correct
51 Correct 1 ms 588 KB Output is correct
52 Correct 1 ms 588 KB Output is correct
53 Correct 1 ms 588 KB Output is correct
54 Correct 1 ms 588 KB Output is correct
55 Correct 2 ms 588 KB Output is correct
56 Correct 2 ms 588 KB Output is correct
57 Correct 2 ms 584 KB Output is correct
58 Correct 1 ms 460 KB Output is correct
59 Correct 1 ms 460 KB Output is correct
60 Correct 1 ms 460 KB Output is correct
61 Correct 1 ms 588 KB Output is correct
62 Correct 1 ms 460 KB Output is correct
63 Correct 1 ms 460 KB Output is correct
64 Correct 1 ms 460 KB Output is correct
65 Correct 1 ms 588 KB Output is correct
66 Correct 1 ms 460 KB Output is correct
67 Correct 1 ms 460 KB Output is correct
68 Correct 1 ms 460 KB Output is correct
69 Correct 1 ms 460 KB Output is correct
70 Correct 1 ms 460 KB Output is correct
71 Correct 124 ms 5176 KB Output is correct
72 Correct 74 ms 3020 KB Output is correct
73 Correct 142 ms 5072 KB Output is correct
74 Correct 58 ms 1956 KB Output is correct
75 Correct 82 ms 2904 KB Output is correct
76 Correct 275 ms 9376 KB Output is correct
77 Correct 303 ms 9192 KB Output is correct
78 Correct 202 ms 5048 KB Output is correct
79 Correct 222 ms 5044 KB Output is correct
80 Correct 1 ms 464 KB Output is correct
81 Correct 1 ms 464 KB Output is correct
82 Correct 1 ms 588 KB Output is correct
83 Correct 21 ms 1216 KB Output is correct
84 Correct 22 ms 1284 KB Output is correct
85 Correct 4 ms 716 KB Output is correct
86 Correct 1 ms 460 KB Output is correct
87 Correct 20 ms 1276 KB Output is correct
88 Correct 1 ms 460 KB Output is correct
89 Correct 1 ms 460 KB Output is correct
90 Correct 1 ms 460 KB Output is correct
91 Correct 6 ms 716 KB Output is correct
92 Correct 22 ms 1372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 460 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 1 ms 460 KB Output is correct
13 Correct 1 ms 460 KB Output is correct
14 Correct 1 ms 460 KB Output is correct
15 Correct 1 ms 512 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 1 ms 460 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
33 Correct 1 ms 460 KB Output is correct
34 Correct 1 ms 460 KB Output is correct
35 Correct 1 ms 460 KB Output is correct
36 Correct 1 ms 460 KB Output is correct
37 Correct 1 ms 460 KB Output is correct
38 Correct 1 ms 460 KB Output is correct
39 Correct 1 ms 460 KB Output is correct
40 Correct 1 ms 460 KB Output is correct
41 Correct 1 ms 460 KB Output is correct
42 Correct 1 ms 460 KB Output is correct
43 Correct 1 ms 460 KB Output is correct
44 Correct 1 ms 460 KB Output is correct
45 Correct 1 ms 460 KB Output is correct
46 Correct 1 ms 460 KB Output is correct
47 Correct 1 ms 460 KB Output is correct
48 Correct 1 ms 460 KB Output is correct
49 Correct 1 ms 460 KB Output is correct
50 Correct 2 ms 588 KB Output is correct
51 Correct 1 ms 588 KB Output is correct
52 Correct 1 ms 588 KB Output is correct
53 Correct 1 ms 588 KB Output is correct
54 Correct 1 ms 588 KB Output is correct
55 Correct 2 ms 588 KB Output is correct
56 Correct 2 ms 588 KB Output is correct
57 Correct 2 ms 584 KB Output is correct
58 Correct 1 ms 460 KB Output is correct
59 Correct 1 ms 460 KB Output is correct
60 Correct 1 ms 460 KB Output is correct
61 Correct 1 ms 588 KB Output is correct
62 Correct 1 ms 460 KB Output is correct
63 Correct 1 ms 460 KB Output is correct
64 Correct 1 ms 460 KB Output is correct
65 Correct 1 ms 588 KB Output is correct
66 Correct 1 ms 460 KB Output is correct
67 Correct 1 ms 460 KB Output is correct
68 Correct 1 ms 460 KB Output is correct
69 Correct 1 ms 460 KB Output is correct
70 Correct 1 ms 460 KB Output is correct
71 Correct 124 ms 5176 KB Output is correct
72 Correct 74 ms 3020 KB Output is correct
73 Correct 142 ms 5072 KB Output is correct
74 Correct 58 ms 1956 KB Output is correct
75 Correct 82 ms 2904 KB Output is correct
76 Correct 275 ms 9376 KB Output is correct
77 Correct 303 ms 9192 KB Output is correct
78 Correct 202 ms 5048 KB Output is correct
79 Correct 222 ms 5044 KB Output is correct
80 Correct 1 ms 464 KB Output is correct
81 Correct 1 ms 464 KB Output is correct
82 Correct 1 ms 588 KB Output is correct
83 Correct 21 ms 1216 KB Output is correct
84 Correct 22 ms 1284 KB Output is correct
85 Correct 4 ms 716 KB Output is correct
86 Correct 1 ms 460 KB Output is correct
87 Correct 20 ms 1276 KB Output is correct
88 Correct 1 ms 460 KB Output is correct
89 Correct 1 ms 460 KB Output is correct
90 Correct 1 ms 460 KB Output is correct
91 Correct 6 ms 716 KB Output is correct
92 Correct 22 ms 1372 KB Output is correct
93 Correct 1050 ms 18512 KB Output is correct
94 Correct 413 ms 9924 KB Output is correct
95 Correct 606 ms 18200 KB Output is correct
96 Correct 514 ms 9896 KB Output is correct
97 Correct 501 ms 9664 KB Output is correct
98 Correct 1323 ms 34788 KB Output is correct
99 Correct 1549 ms 34848 KB Output is correct
100 Correct 1285 ms 34800 KB Output is correct
101 Correct 1641 ms 34628 KB Output is correct
102 Correct 1375 ms 34328 KB Output is correct
103 Correct 720 ms 18124 KB Output is correct
104 Correct 1 ms 460 KB Output is correct
105 Correct 1 ms 460 KB Output is correct
106 Correct 3 ms 588 KB Output is correct
107 Correct 80 ms 2768 KB Output is correct
108 Correct 186 ms 4824 KB Output is correct
109 Correct 10 ms 868 KB Output is correct
110 Correct 1 ms 460 KB Output is correct
111 Correct 66 ms 2768 KB Output is correct
112 Correct 1 ms 460 KB Output is correct
113 Correct 1 ms 460 KB Output is correct
114 Correct 4 ms 588 KB Output is correct
115 Correct 1 ms 460 KB Output is correct
116 Correct 5 ms 696 KB Output is correct
117 Correct 100 ms 3188 KB Output is correct