답안 #942959

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
942959 2024-03-11T07:20:55 Z viwlesxq Toys (CEOI18_toy) C++17
100 / 100
2319 ms 73880 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define size(x) (int)x.size()

template<class S, class T>
bool chmin(S &a, const T &b) {
  return a > b ? (a = b) == b : false;
}
template<class S, class T>
bool chmax(S &a, const T &b) {
  return a < b ? (a = b) == b : false;
}
const int N = 1e5;

unordered_map<int, unordered_map<int, bool>> vis;
int sum = 0;

void solve(int n) {
  sum += n - 1;
  vis[sum][n] = true;
  sum -= n - 1;
  for (int d = 2; d * d <= n; ++d) {
    if (n % d == 0) {
      sum += d - 1;
      if (!vis[sum + n / d - 1][n / d]) solve(n / d);
      sum -= d - 1;
    }
  }
}

signed main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n; cin >> n;
  solve(n);
  vector<int> res;
  for (auto [i, j] : vis) {
    res.push_back(i);
  }
  sort(all(res));
  cout << size(res) << '\n';
  for (auto i : res) cout << i << ' ';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 344 KB Output is correct
50 Correct 2 ms 600 KB Output is correct
51 Correct 1 ms 604 KB Output is correct
52 Correct 1 ms 604 KB Output is correct
53 Correct 1 ms 604 KB Output is correct
54 Correct 1 ms 344 KB Output is correct
55 Correct 2 ms 800 KB Output is correct
56 Correct 2 ms 604 KB Output is correct
57 Correct 2 ms 600 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 1 ms 604 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 1 ms 372 KB Output is correct
64 Correct 1 ms 348 KB Output is correct
65 Correct 2 ms 776 KB Output is correct
66 Correct 1 ms 344 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 344 KB Output is correct
50 Correct 2 ms 600 KB Output is correct
51 Correct 1 ms 604 KB Output is correct
52 Correct 1 ms 604 KB Output is correct
53 Correct 1 ms 604 KB Output is correct
54 Correct 1 ms 344 KB Output is correct
55 Correct 2 ms 800 KB Output is correct
56 Correct 2 ms 604 KB Output is correct
57 Correct 2 ms 600 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 1 ms 604 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 1 ms 372 KB Output is correct
64 Correct 1 ms 348 KB Output is correct
65 Correct 2 ms 776 KB Output is correct
66 Correct 1 ms 344 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
71 Correct 180 ms 16180 KB Output is correct
72 Correct 115 ms 12400 KB Output is correct
73 Correct 166 ms 14340 KB Output is correct
74 Correct 81 ms 9764 KB Output is correct
75 Correct 101 ms 10548 KB Output is correct
76 Correct 403 ms 21852 KB Output is correct
77 Correct 302 ms 19384 KB Output is correct
78 Correct 263 ms 18000 KB Output is correct
79 Correct 301 ms 17584 KB Output is correct
80 Correct 0 ms 348 KB Output is correct
81 Correct 1 ms 348 KB Output is correct
82 Correct 2 ms 860 KB Output is correct
83 Correct 23 ms 3420 KB Output is correct
84 Correct 29 ms 4212 KB Output is correct
85 Correct 9 ms 1520 KB Output is correct
86 Correct 1 ms 348 KB Output is correct
87 Correct 34 ms 4720 KB Output is correct
88 Correct 1 ms 500 KB Output is correct
89 Correct 0 ms 348 KB Output is correct
90 Correct 1 ms 348 KB Output is correct
91 Correct 12 ms 2140 KB Output is correct
92 Correct 43 ms 6256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 344 KB Output is correct
44 Correct 0 ms 344 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 344 KB Output is correct
50 Correct 2 ms 600 KB Output is correct
51 Correct 1 ms 604 KB Output is correct
52 Correct 1 ms 604 KB Output is correct
53 Correct 1 ms 604 KB Output is correct
54 Correct 1 ms 344 KB Output is correct
55 Correct 2 ms 800 KB Output is correct
56 Correct 2 ms 604 KB Output is correct
57 Correct 2 ms 600 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 1 ms 604 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 1 ms 372 KB Output is correct
64 Correct 1 ms 348 KB Output is correct
65 Correct 2 ms 776 KB Output is correct
66 Correct 1 ms 344 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 0 ms 348 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
71 Correct 180 ms 16180 KB Output is correct
72 Correct 115 ms 12400 KB Output is correct
73 Correct 166 ms 14340 KB Output is correct
74 Correct 81 ms 9764 KB Output is correct
75 Correct 101 ms 10548 KB Output is correct
76 Correct 403 ms 21852 KB Output is correct
77 Correct 302 ms 19384 KB Output is correct
78 Correct 263 ms 18000 KB Output is correct
79 Correct 301 ms 17584 KB Output is correct
80 Correct 0 ms 348 KB Output is correct
81 Correct 1 ms 348 KB Output is correct
82 Correct 2 ms 860 KB Output is correct
83 Correct 23 ms 3420 KB Output is correct
84 Correct 29 ms 4212 KB Output is correct
85 Correct 9 ms 1520 KB Output is correct
86 Correct 1 ms 348 KB Output is correct
87 Correct 34 ms 4720 KB Output is correct
88 Correct 1 ms 500 KB Output is correct
89 Correct 0 ms 348 KB Output is correct
90 Correct 1 ms 348 KB Output is correct
91 Correct 12 ms 2140 KB Output is correct
92 Correct 43 ms 6256 KB Output is correct
93 Correct 2144 ms 66120 KB Output is correct
94 Correct 1176 ms 45628 KB Output is correct
95 Correct 1211 ms 47648 KB Output is correct
96 Correct 1038 ms 42588 KB Output is correct
97 Correct 846 ms 39068 KB Output is correct
98 Correct 2226 ms 72756 KB Output is correct
99 Correct 2319 ms 73880 KB Output is correct
100 Correct 2145 ms 70964 KB Output is correct
101 Correct 1927 ms 66768 KB Output is correct
102 Correct 1763 ms 60436 KB Output is correct
103 Correct 1457 ms 54052 KB Output is correct
104 Correct 1 ms 348 KB Output is correct
105 Correct 1 ms 348 KB Output is correct
106 Correct 5 ms 1116 KB Output is correct
107 Correct 77 ms 9132 KB Output is correct
108 Correct 235 ms 18344 KB Output is correct
109 Correct 24 ms 3420 KB Output is correct
110 Correct 1 ms 348 KB Output is correct
111 Correct 107 ms 11004 KB Output is correct
112 Correct 1 ms 348 KB Output is correct
113 Correct 1 ms 348 KB Output is correct
114 Correct 8 ms 1116 KB Output is correct
115 Correct 1 ms 348 KB Output is correct
116 Correct 17 ms 1760 KB Output is correct
117 Correct 287 ms 21892 KB Output is correct