답안 #651094

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
651094 2022-10-17T03:39:48 Z ghostwriter Toys (CEOI18_toy) C++14
100 / 100
1265 ms 25788 KB
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#else
#define debug(...)
#endif
#define ft front
#define bk back
#define st first
#define nd second
#define ins insert
#define ers erase
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define bg begin
#define ed end
#define all(x) x.bg(), x.ed()
#define sz(x) (int)x.size()
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define FOR(i, l, r) for (int i = l; i <= r; ++i)
#define FOS(i, r, l) for (int i = r; i >= l; --i)
#define FRN(i, n) for (int i = 0; i < n; ++i)
#define FSN(i, n) for (int i = n - 1; i >= 0; --i)
#define EACH(i, x) for (auto &i : x)
#define WHILE while
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
----------------------------------------------------------------
    END OF TEMPLATE
----------------------------------------------------------------
    Tran The Bao - ghostwriter
    Training for VOI23 gold medal
----------------------------------------------------------------
    GOAT
----------------------------------------------------------------
*/
const int N = 3001;
int n;
vi ans[N];
vi getd(int n) {
	vi ans;
	for (int i = 1; 1LL * i * i <= n; ++i) {
		if (n % i != 0) continue;
		int a = i, b = n / i;
		ans.pb(a);
		if (b != a) ans.pb(b);
	}
	return ans;
}
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // freopen(file".inp", "r", stdin);
    // freopen(file".out", "w", stdout);
    cin >> n;
    vi d = getd(n);
    sort(all(d));
    FRN(i, sz(d)) {
    	ans[i].pb(d[i] - 1);
    	FRN(j, i) {
    		if (d[i] % d[j] != 0) continue;
			EACH(z, ans[j])
				ans[i].pb(z + d[i] / d[j] - 1);
		}
		sort(all(ans[i]));
		vi ans1;
		ans1.pb(ans[i][0]);
		FOR(j, 1, sz(ans[i]) - 1)
			if (ans[i][j] != ans[i][j - 1])
				ans1.pb(ans[i][j]);
		swap(ans[i], ans1);
    }
    cout << sz(ans[sz(d) - 1]) << '\n';
    EACH(i, ans[sz(d) - 1]) cout << i << ' ';
    return 0;
}
/*
12
----------------------------------------------------------------
From Benq:
    stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
        * DON'T GET STUCK ON ONE APPROACH
----------------------------------------------------------------
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 396 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 396 KB Output is correct
8 Correct 1 ms 400 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 396 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 396 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 400 KB Output is correct
18 Correct 1 ms 400 KB Output is correct
19 Correct 1 ms 396 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 396 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 396 KB Output is correct
8 Correct 1 ms 400 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 396 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 396 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 400 KB Output is correct
18 Correct 1 ms 400 KB Output is correct
19 Correct 1 ms 396 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 396 KB Output is correct
30 Correct 1 ms 396 KB Output is correct
31 Correct 1 ms 392 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 400 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 396 KB Output is correct
38 Correct 1 ms 400 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 396 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 396 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 396 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 396 KB Output is correct
8 Correct 1 ms 400 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 396 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 396 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 400 KB Output is correct
18 Correct 1 ms 400 KB Output is correct
19 Correct 1 ms 396 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 396 KB Output is correct
30 Correct 1 ms 396 KB Output is correct
31 Correct 1 ms 392 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 400 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 396 KB Output is correct
38 Correct 1 ms 400 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 396 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 396 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 3 ms 468 KB Output is correct
51 Correct 2 ms 392 KB Output is correct
52 Correct 2 ms 468 KB Output is correct
53 Correct 2 ms 468 KB Output is correct
54 Correct 2 ms 396 KB Output is correct
55 Correct 3 ms 468 KB Output is correct
56 Correct 3 ms 468 KB Output is correct
57 Correct 3 ms 468 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 2 ms 340 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 340 KB Output is correct
65 Correct 2 ms 340 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 468 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 396 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 396 KB Output is correct
8 Correct 1 ms 400 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 396 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 396 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 400 KB Output is correct
18 Correct 1 ms 400 KB Output is correct
19 Correct 1 ms 396 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 396 KB Output is correct
30 Correct 1 ms 396 KB Output is correct
31 Correct 1 ms 392 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 400 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 396 KB Output is correct
38 Correct 1 ms 400 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 396 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 396 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 3 ms 468 KB Output is correct
51 Correct 2 ms 392 KB Output is correct
52 Correct 2 ms 468 KB Output is correct
53 Correct 2 ms 468 KB Output is correct
54 Correct 2 ms 396 KB Output is correct
55 Correct 3 ms 468 KB Output is correct
56 Correct 3 ms 468 KB Output is correct
57 Correct 3 ms 468 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 2 ms 340 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 340 KB Output is correct
65 Correct 2 ms 340 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 468 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
71 Correct 193 ms 5972 KB Output is correct
72 Correct 134 ms 5004 KB Output is correct
73 Correct 169 ms 5560 KB Output is correct
74 Correct 94 ms 3448 KB Output is correct
75 Correct 109 ms 3616 KB Output is correct
76 Correct 284 ms 7224 KB Output is correct
77 Correct 279 ms 6580 KB Output is correct
78 Correct 226 ms 5756 KB Output is correct
79 Correct 236 ms 6292 KB Output is correct
80 Correct 1 ms 340 KB Output is correct
81 Correct 1 ms 340 KB Output is correct
82 Correct 2 ms 392 KB Output is correct
83 Correct 26 ms 1188 KB Output is correct
84 Correct 32 ms 1552 KB Output is correct
85 Correct 8 ms 652 KB Output is correct
86 Correct 1 ms 340 KB Output is correct
87 Correct 38 ms 1584 KB Output is correct
88 Correct 1 ms 340 KB Output is correct
89 Correct 1 ms 340 KB Output is correct
90 Correct 1 ms 340 KB Output is correct
91 Correct 10 ms 784 KB Output is correct
92 Correct 53 ms 1744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 396 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 396 KB Output is correct
8 Correct 1 ms 400 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 396 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 396 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 400 KB Output is correct
18 Correct 1 ms 400 KB Output is correct
19 Correct 1 ms 396 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 2 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 396 KB Output is correct
30 Correct 1 ms 396 KB Output is correct
31 Correct 1 ms 392 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 400 KB Output is correct
34 Correct 1 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 396 KB Output is correct
38 Correct 1 ms 400 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 396 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 1 ms 340 KB Output is correct
45 Correct 1 ms 340 KB Output is correct
46 Correct 1 ms 396 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 1 ms 340 KB Output is correct
49 Correct 1 ms 340 KB Output is correct
50 Correct 3 ms 468 KB Output is correct
51 Correct 2 ms 392 KB Output is correct
52 Correct 2 ms 468 KB Output is correct
53 Correct 2 ms 468 KB Output is correct
54 Correct 2 ms 396 KB Output is correct
55 Correct 3 ms 468 KB Output is correct
56 Correct 3 ms 468 KB Output is correct
57 Correct 3 ms 468 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 1 ms 340 KB Output is correct
60 Correct 1 ms 340 KB Output is correct
61 Correct 2 ms 340 KB Output is correct
62 Correct 1 ms 340 KB Output is correct
63 Correct 1 ms 340 KB Output is correct
64 Correct 1 ms 340 KB Output is correct
65 Correct 2 ms 340 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 468 KB Output is correct
68 Correct 1 ms 340 KB Output is correct
69 Correct 1 ms 340 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
71 Correct 193 ms 5972 KB Output is correct
72 Correct 134 ms 5004 KB Output is correct
73 Correct 169 ms 5560 KB Output is correct
74 Correct 94 ms 3448 KB Output is correct
75 Correct 109 ms 3616 KB Output is correct
76 Correct 284 ms 7224 KB Output is correct
77 Correct 279 ms 6580 KB Output is correct
78 Correct 226 ms 5756 KB Output is correct
79 Correct 236 ms 6292 KB Output is correct
80 Correct 1 ms 340 KB Output is correct
81 Correct 1 ms 340 KB Output is correct
82 Correct 2 ms 392 KB Output is correct
83 Correct 26 ms 1188 KB Output is correct
84 Correct 32 ms 1552 KB Output is correct
85 Correct 8 ms 652 KB Output is correct
86 Correct 1 ms 340 KB Output is correct
87 Correct 38 ms 1584 KB Output is correct
88 Correct 1 ms 340 KB Output is correct
89 Correct 1 ms 340 KB Output is correct
90 Correct 1 ms 340 KB Output is correct
91 Correct 10 ms 784 KB Output is correct
92 Correct 53 ms 1744 KB Output is correct
93 Correct 1079 ms 23504 KB Output is correct
94 Correct 585 ms 14848 KB Output is correct
95 Correct 709 ms 19124 KB Output is correct
96 Correct 586 ms 13968 KB Output is correct
97 Correct 536 ms 13200 KB Output is correct
98 Correct 1225 ms 25344 KB Output is correct
99 Correct 1265 ms 25788 KB Output is correct
100 Correct 1156 ms 25096 KB Output is correct
101 Correct 1092 ms 24032 KB Output is correct
102 Correct 1018 ms 22040 KB Output is correct
103 Correct 774 ms 20620 KB Output is correct
104 Correct 1 ms 340 KB Output is correct
105 Correct 1 ms 400 KB Output is correct
106 Correct 4 ms 524 KB Output is correct
107 Correct 94 ms 3032 KB Output is correct
108 Correct 213 ms 6500 KB Output is correct
109 Correct 20 ms 1164 KB Output is correct
110 Correct 1 ms 340 KB Output is correct
111 Correct 111 ms 3660 KB Output is correct
112 Correct 1 ms 340 KB Output is correct
113 Correct 1 ms 340 KB Output is correct
114 Correct 3 ms 520 KB Output is correct
115 Correct 1 ms 396 KB Output is correct
116 Correct 9 ms 700 KB Output is correct
117 Correct 208 ms 6840 KB Output is correct