답안 #457870

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
457870 2021-08-07T13:05:43 Z hhhhaura Toys (CEOI18_toy) C++14
79 / 100
5000 ms 57788 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;
	set<pii> vis;
	void solve(int n, int sum) {
		if(vis.find({n, sum}) != vis.end()) return;
		if(n == 1) {
			ans.push_back(sum);
			return;
		}
		for(int i = 2; i * i <= n; i ++) {
			if(n % i) continue;
			solve(n / i, sum + i - 1);
			solve(i, sum + n / i - 1);
		}
		solve(1, sum + n - 1);
		vis.insert({n, sum});
		return;
	}
	


};
using namespace solver;
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n; 
	cin >> n;
	solve(n, 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:63: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]
   63 |   cout << ans[i] << " \n"[i + 1 == ans.size()];
      |                           ~~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 312 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 312 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 5 ms 588 KB Output is correct
51 Correct 6 ms 588 KB Output is correct
52 Correct 5 ms 588 KB Output is correct
53 Correct 5 ms 588 KB Output is correct
54 Correct 2 ms 460 KB Output is correct
55 Correct 8 ms 824 KB Output is correct
56 Correct 7 ms 716 KB Output is correct
57 Correct 7 ms 716 KB Output is correct
58 Correct 1 ms 204 KB Output is correct
59 Correct 1 ms 316 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 3 ms 460 KB Output is correct
62 Correct 2 ms 332 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 3 ms 460 KB Output is correct
66 Correct 0 ms 204 KB Output is correct
67 Correct 0 ms 204 KB Output is correct
68 Correct 1 ms 316 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 312 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 5 ms 588 KB Output is correct
51 Correct 6 ms 588 KB Output is correct
52 Correct 5 ms 588 KB Output is correct
53 Correct 5 ms 588 KB Output is correct
54 Correct 2 ms 460 KB Output is correct
55 Correct 8 ms 824 KB Output is correct
56 Correct 7 ms 716 KB Output is correct
57 Correct 7 ms 716 KB Output is correct
58 Correct 1 ms 204 KB Output is correct
59 Correct 1 ms 316 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 3 ms 460 KB Output is correct
62 Correct 2 ms 332 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 3 ms 460 KB Output is correct
66 Correct 0 ms 204 KB Output is correct
67 Correct 0 ms 204 KB Output is correct
68 Correct 1 ms 316 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 2 ms 332 KB Output is correct
71 Correct 1529 ms 25916 KB Output is correct
72 Correct 955 ms 20836 KB Output is correct
73 Correct 1438 ms 23268 KB Output is correct
74 Correct 693 ms 15452 KB Output is correct
75 Correct 808 ms 16540 KB Output is correct
76 Correct 2764 ms 35296 KB Output is correct
77 Correct 2465 ms 30928 KB Output is correct
78 Correct 2207 ms 28984 KB Output is correct
79 Correct 2003 ms 28180 KB Output is correct
80 Correct 1 ms 204 KB Output is correct
81 Correct 1 ms 204 KB Output is correct
82 Correct 6 ms 716 KB Output is correct
83 Correct 124 ms 4664 KB Output is correct
84 Correct 158 ms 5792 KB Output is correct
85 Correct 31 ms 1864 KB Output is correct
86 Correct 1 ms 332 KB Output is correct
87 Correct 198 ms 6664 KB Output is correct
88 Correct 1 ms 204 KB Output is correct
89 Correct 1 ms 308 KB Output is correct
90 Correct 2 ms 332 KB Output is correct
91 Correct 41 ms 2548 KB Output is correct
92 Correct 259 ms 8652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 0 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 2 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 312 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 332 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 332 KB Output is correct
41 Correct 0 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 5 ms 588 KB Output is correct
51 Correct 6 ms 588 KB Output is correct
52 Correct 5 ms 588 KB Output is correct
53 Correct 5 ms 588 KB Output is correct
54 Correct 2 ms 460 KB Output is correct
55 Correct 8 ms 824 KB Output is correct
56 Correct 7 ms 716 KB Output is correct
57 Correct 7 ms 716 KB Output is correct
58 Correct 1 ms 204 KB Output is correct
59 Correct 1 ms 316 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 3 ms 460 KB Output is correct
62 Correct 2 ms 332 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 0 ms 204 KB Output is correct
65 Correct 3 ms 460 KB Output is correct
66 Correct 0 ms 204 KB Output is correct
67 Correct 0 ms 204 KB Output is correct
68 Correct 1 ms 316 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 2 ms 332 KB Output is correct
71 Correct 1529 ms 25916 KB Output is correct
72 Correct 955 ms 20836 KB Output is correct
73 Correct 1438 ms 23268 KB Output is correct
74 Correct 693 ms 15452 KB Output is correct
75 Correct 808 ms 16540 KB Output is correct
76 Correct 2764 ms 35296 KB Output is correct
77 Correct 2465 ms 30928 KB Output is correct
78 Correct 2207 ms 28984 KB Output is correct
79 Correct 2003 ms 28180 KB Output is correct
80 Correct 1 ms 204 KB Output is correct
81 Correct 1 ms 204 KB Output is correct
82 Correct 6 ms 716 KB Output is correct
83 Correct 124 ms 4664 KB Output is correct
84 Correct 158 ms 5792 KB Output is correct
85 Correct 31 ms 1864 KB Output is correct
86 Correct 1 ms 332 KB Output is correct
87 Correct 198 ms 6664 KB Output is correct
88 Correct 1 ms 204 KB Output is correct
89 Correct 1 ms 308 KB Output is correct
90 Correct 2 ms 332 KB Output is correct
91 Correct 41 ms 2548 KB Output is correct
92 Correct 259 ms 8652 KB Output is correct
93 Execution timed out 5087 ms 57788 KB Time limit exceeded
94 Halted 0 ms 0 KB -