답안 #699256

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
699256 2023-02-16T09:36:19 Z dattranxxx Toys (CEOI18_toy) C++11
79 / 100
5000 ms 74548 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 1e5 + 5;

int n;
vector<int> divi[N];
map<int, bool> vis[N];

int main() {
  cin.tie(0)->sync_with_stdio(0); cout.tie(0);
  cin >> n;
  vector<int> d;
  for (int i = 2; i * i <= n; ++i) if (n % i == 0) {
    d.emplace_back(i);
    if (i * i != n) d.emplace_back(n / i);
  }
  d.emplace_back(n);
  sort(d.begin(), d.end());

  
  queue<pair<int, int>> q;
  q.emplace(d.size() - 1, 0);
  
  while (!q.empty()) {
    int i, s; tie(i, s) = q.front(); q.pop();
    for (int j = 0; j < i; ++j) if (d[i] % d[j] == 0) {
      int k = lower_bound(d.begin(), d.end(), d[i] / d[j]) - d.begin();
      if (!vis[k][s + d[j] - 1]) {
        q.emplace(k, s + d[j] - 1);
        vis[k][s + d[j] - 1] = 1;
      }
    }
    
    vis[d.size()][s + d[i] - 1] = 1;
  }
  
  cout << vis[d.size()].size() << '\n';
  for (auto& x : vis[d.size()]) {
    cout << x.first << ' ';
  }
  
  
  
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 4 ms 7372 KB Output is correct
4 Correct 5 ms 7376 KB Output is correct
5 Correct 4 ms 7252 KB Output is correct
6 Correct 4 ms 7252 KB Output is correct
7 Correct 4 ms 7280 KB Output is correct
8 Correct 4 ms 7368 KB Output is correct
9 Correct 4 ms 7252 KB Output is correct
10 Correct 5 ms 7252 KB Output is correct
11 Correct 4 ms 7376 KB Output is correct
12 Correct 4 ms 7252 KB Output is correct
13 Correct 3 ms 7252 KB Output is correct
14 Correct 4 ms 7372 KB Output is correct
15 Correct 6 ms 7252 KB Output is correct
16 Correct 4 ms 7252 KB Output is correct
17 Correct 4 ms 7372 KB Output is correct
18 Correct 5 ms 7252 KB Output is correct
19 Correct 4 ms 7372 KB Output is correct
20 Correct 4 ms 7252 KB Output is correct
21 Correct 3 ms 7372 KB Output is correct
22 Correct 4 ms 7252 KB Output is correct
23 Correct 4 ms 7372 KB Output is correct
24 Correct 4 ms 7272 KB Output is correct
25 Correct 4 ms 7348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 4 ms 7372 KB Output is correct
4 Correct 5 ms 7376 KB Output is correct
5 Correct 4 ms 7252 KB Output is correct
6 Correct 4 ms 7252 KB Output is correct
7 Correct 4 ms 7280 KB Output is correct
8 Correct 4 ms 7368 KB Output is correct
9 Correct 4 ms 7252 KB Output is correct
10 Correct 5 ms 7252 KB Output is correct
11 Correct 4 ms 7376 KB Output is correct
12 Correct 4 ms 7252 KB Output is correct
13 Correct 3 ms 7252 KB Output is correct
14 Correct 4 ms 7372 KB Output is correct
15 Correct 6 ms 7252 KB Output is correct
16 Correct 4 ms 7252 KB Output is correct
17 Correct 4 ms 7372 KB Output is correct
18 Correct 5 ms 7252 KB Output is correct
19 Correct 4 ms 7372 KB Output is correct
20 Correct 4 ms 7252 KB Output is correct
21 Correct 3 ms 7372 KB Output is correct
22 Correct 4 ms 7252 KB Output is correct
23 Correct 4 ms 7372 KB Output is correct
24 Correct 4 ms 7272 KB Output is correct
25 Correct 4 ms 7348 KB Output is correct
26 Correct 4 ms 7380 KB Output is correct
27 Correct 5 ms 7500 KB Output is correct
28 Correct 6 ms 7528 KB Output is correct
29 Correct 4 ms 7380 KB Output is correct
30 Correct 4 ms 7296 KB Output is correct
31 Correct 6 ms 7372 KB Output is correct
32 Correct 5 ms 7380 KB Output is correct
33 Correct 4 ms 7380 KB Output is correct
34 Correct 4 ms 7252 KB Output is correct
35 Correct 4 ms 7252 KB Output is correct
36 Correct 5 ms 7380 KB Output is correct
37 Correct 4 ms 7376 KB Output is correct
38 Correct 4 ms 7380 KB Output is correct
39 Correct 4 ms 7372 KB Output is correct
40 Correct 4 ms 7380 KB Output is correct
41 Correct 4 ms 7252 KB Output is correct
42 Correct 4 ms 7252 KB Output is correct
43 Correct 5 ms 7372 KB Output is correct
44 Correct 6 ms 7252 KB Output is correct
45 Correct 4 ms 7380 KB Output is correct
46 Correct 4 ms 7284 KB Output is correct
47 Correct 5 ms 7376 KB Output is correct
48 Correct 4 ms 7252 KB Output is correct
49 Correct 4 ms 7380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 4 ms 7372 KB Output is correct
4 Correct 5 ms 7376 KB Output is correct
5 Correct 4 ms 7252 KB Output is correct
6 Correct 4 ms 7252 KB Output is correct
7 Correct 4 ms 7280 KB Output is correct
8 Correct 4 ms 7368 KB Output is correct
9 Correct 4 ms 7252 KB Output is correct
10 Correct 5 ms 7252 KB Output is correct
11 Correct 4 ms 7376 KB Output is correct
12 Correct 4 ms 7252 KB Output is correct
13 Correct 3 ms 7252 KB Output is correct
14 Correct 4 ms 7372 KB Output is correct
15 Correct 6 ms 7252 KB Output is correct
16 Correct 4 ms 7252 KB Output is correct
17 Correct 4 ms 7372 KB Output is correct
18 Correct 5 ms 7252 KB Output is correct
19 Correct 4 ms 7372 KB Output is correct
20 Correct 4 ms 7252 KB Output is correct
21 Correct 3 ms 7372 KB Output is correct
22 Correct 4 ms 7252 KB Output is correct
23 Correct 4 ms 7372 KB Output is correct
24 Correct 4 ms 7272 KB Output is correct
25 Correct 4 ms 7348 KB Output is correct
26 Correct 4 ms 7380 KB Output is correct
27 Correct 5 ms 7500 KB Output is correct
28 Correct 6 ms 7528 KB Output is correct
29 Correct 4 ms 7380 KB Output is correct
30 Correct 4 ms 7296 KB Output is correct
31 Correct 6 ms 7372 KB Output is correct
32 Correct 5 ms 7380 KB Output is correct
33 Correct 4 ms 7380 KB Output is correct
34 Correct 4 ms 7252 KB Output is correct
35 Correct 4 ms 7252 KB Output is correct
36 Correct 5 ms 7380 KB Output is correct
37 Correct 4 ms 7376 KB Output is correct
38 Correct 4 ms 7380 KB Output is correct
39 Correct 4 ms 7372 KB Output is correct
40 Correct 4 ms 7380 KB Output is correct
41 Correct 4 ms 7252 KB Output is correct
42 Correct 4 ms 7252 KB Output is correct
43 Correct 5 ms 7372 KB Output is correct
44 Correct 6 ms 7252 KB Output is correct
45 Correct 4 ms 7380 KB Output is correct
46 Correct 4 ms 7284 KB Output is correct
47 Correct 5 ms 7376 KB Output is correct
48 Correct 4 ms 7252 KB Output is correct
49 Correct 4 ms 7380 KB Output is correct
50 Correct 7 ms 7636 KB Output is correct
51 Correct 7 ms 7624 KB Output is correct
52 Correct 7 ms 7508 KB Output is correct
53 Correct 6 ms 7496 KB Output is correct
54 Correct 5 ms 7508 KB Output is correct
55 Correct 9 ms 7636 KB Output is correct
56 Correct 9 ms 7636 KB Output is correct
57 Correct 8 ms 7636 KB Output is correct
58 Correct 3 ms 7252 KB Output is correct
59 Correct 4 ms 7260 KB Output is correct
60 Correct 4 ms 7380 KB Output is correct
61 Correct 6 ms 7508 KB Output is correct
62 Correct 6 ms 7380 KB Output is correct
63 Correct 4 ms 7380 KB Output is correct
64 Correct 6 ms 7372 KB Output is correct
65 Correct 6 ms 7508 KB Output is correct
66 Correct 4 ms 7252 KB Output is correct
67 Correct 4 ms 7252 KB Output is correct
68 Correct 4 ms 7348 KB Output is correct
69 Correct 5 ms 7368 KB Output is correct
70 Correct 5 ms 7372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 4 ms 7372 KB Output is correct
4 Correct 5 ms 7376 KB Output is correct
5 Correct 4 ms 7252 KB Output is correct
6 Correct 4 ms 7252 KB Output is correct
7 Correct 4 ms 7280 KB Output is correct
8 Correct 4 ms 7368 KB Output is correct
9 Correct 4 ms 7252 KB Output is correct
10 Correct 5 ms 7252 KB Output is correct
11 Correct 4 ms 7376 KB Output is correct
12 Correct 4 ms 7252 KB Output is correct
13 Correct 3 ms 7252 KB Output is correct
14 Correct 4 ms 7372 KB Output is correct
15 Correct 6 ms 7252 KB Output is correct
16 Correct 4 ms 7252 KB Output is correct
17 Correct 4 ms 7372 KB Output is correct
18 Correct 5 ms 7252 KB Output is correct
19 Correct 4 ms 7372 KB Output is correct
20 Correct 4 ms 7252 KB Output is correct
21 Correct 3 ms 7372 KB Output is correct
22 Correct 4 ms 7252 KB Output is correct
23 Correct 4 ms 7372 KB Output is correct
24 Correct 4 ms 7272 KB Output is correct
25 Correct 4 ms 7348 KB Output is correct
26 Correct 4 ms 7380 KB Output is correct
27 Correct 5 ms 7500 KB Output is correct
28 Correct 6 ms 7528 KB Output is correct
29 Correct 4 ms 7380 KB Output is correct
30 Correct 4 ms 7296 KB Output is correct
31 Correct 6 ms 7372 KB Output is correct
32 Correct 5 ms 7380 KB Output is correct
33 Correct 4 ms 7380 KB Output is correct
34 Correct 4 ms 7252 KB Output is correct
35 Correct 4 ms 7252 KB Output is correct
36 Correct 5 ms 7380 KB Output is correct
37 Correct 4 ms 7376 KB Output is correct
38 Correct 4 ms 7380 KB Output is correct
39 Correct 4 ms 7372 KB Output is correct
40 Correct 4 ms 7380 KB Output is correct
41 Correct 4 ms 7252 KB Output is correct
42 Correct 4 ms 7252 KB Output is correct
43 Correct 5 ms 7372 KB Output is correct
44 Correct 6 ms 7252 KB Output is correct
45 Correct 4 ms 7380 KB Output is correct
46 Correct 4 ms 7284 KB Output is correct
47 Correct 5 ms 7376 KB Output is correct
48 Correct 4 ms 7252 KB Output is correct
49 Correct 4 ms 7380 KB Output is correct
50 Correct 7 ms 7636 KB Output is correct
51 Correct 7 ms 7624 KB Output is correct
52 Correct 7 ms 7508 KB Output is correct
53 Correct 6 ms 7496 KB Output is correct
54 Correct 5 ms 7508 KB Output is correct
55 Correct 9 ms 7636 KB Output is correct
56 Correct 9 ms 7636 KB Output is correct
57 Correct 8 ms 7636 KB Output is correct
58 Correct 3 ms 7252 KB Output is correct
59 Correct 4 ms 7260 KB Output is correct
60 Correct 4 ms 7380 KB Output is correct
61 Correct 6 ms 7508 KB Output is correct
62 Correct 6 ms 7380 KB Output is correct
63 Correct 4 ms 7380 KB Output is correct
64 Correct 6 ms 7372 KB Output is correct
65 Correct 6 ms 7508 KB Output is correct
66 Correct 4 ms 7252 KB Output is correct
67 Correct 4 ms 7252 KB Output is correct
68 Correct 4 ms 7348 KB Output is correct
69 Correct 5 ms 7368 KB Output is correct
70 Correct 5 ms 7372 KB Output is correct
71 Correct 1123 ms 25508 KB Output is correct
72 Correct 712 ms 21076 KB Output is correct
73 Correct 1004 ms 23524 KB Output is correct
74 Correct 526 ms 18084 KB Output is correct
75 Correct 602 ms 18960 KB Output is correct
76 Correct 1953 ms 31892 KB Output is correct
77 Correct 1572 ms 28888 KB Output is correct
78 Correct 1436 ms 27748 KB Output is correct
79 Correct 1406 ms 27032 KB Output is correct
80 Correct 4 ms 7252 KB Output is correct
81 Correct 4 ms 7372 KB Output is correct
82 Correct 8 ms 7636 KB Output is correct
83 Correct 90 ms 10580 KB Output is correct
84 Correct 119 ms 11344 KB Output is correct
85 Correct 23 ms 8596 KB Output is correct
86 Correct 4 ms 7368 KB Output is correct
87 Correct 133 ms 12024 KB Output is correct
88 Correct 4 ms 7252 KB Output is correct
89 Correct 4 ms 7360 KB Output is correct
90 Correct 5 ms 7380 KB Output is correct
91 Correct 38 ms 9176 KB Output is correct
92 Correct 203 ms 13572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 7252 KB Output is correct
2 Correct 4 ms 7252 KB Output is correct
3 Correct 4 ms 7372 KB Output is correct
4 Correct 5 ms 7376 KB Output is correct
5 Correct 4 ms 7252 KB Output is correct
6 Correct 4 ms 7252 KB Output is correct
7 Correct 4 ms 7280 KB Output is correct
8 Correct 4 ms 7368 KB Output is correct
9 Correct 4 ms 7252 KB Output is correct
10 Correct 5 ms 7252 KB Output is correct
11 Correct 4 ms 7376 KB Output is correct
12 Correct 4 ms 7252 KB Output is correct
13 Correct 3 ms 7252 KB Output is correct
14 Correct 4 ms 7372 KB Output is correct
15 Correct 6 ms 7252 KB Output is correct
16 Correct 4 ms 7252 KB Output is correct
17 Correct 4 ms 7372 KB Output is correct
18 Correct 5 ms 7252 KB Output is correct
19 Correct 4 ms 7372 KB Output is correct
20 Correct 4 ms 7252 KB Output is correct
21 Correct 3 ms 7372 KB Output is correct
22 Correct 4 ms 7252 KB Output is correct
23 Correct 4 ms 7372 KB Output is correct
24 Correct 4 ms 7272 KB Output is correct
25 Correct 4 ms 7348 KB Output is correct
26 Correct 4 ms 7380 KB Output is correct
27 Correct 5 ms 7500 KB Output is correct
28 Correct 6 ms 7528 KB Output is correct
29 Correct 4 ms 7380 KB Output is correct
30 Correct 4 ms 7296 KB Output is correct
31 Correct 6 ms 7372 KB Output is correct
32 Correct 5 ms 7380 KB Output is correct
33 Correct 4 ms 7380 KB Output is correct
34 Correct 4 ms 7252 KB Output is correct
35 Correct 4 ms 7252 KB Output is correct
36 Correct 5 ms 7380 KB Output is correct
37 Correct 4 ms 7376 KB Output is correct
38 Correct 4 ms 7380 KB Output is correct
39 Correct 4 ms 7372 KB Output is correct
40 Correct 4 ms 7380 KB Output is correct
41 Correct 4 ms 7252 KB Output is correct
42 Correct 4 ms 7252 KB Output is correct
43 Correct 5 ms 7372 KB Output is correct
44 Correct 6 ms 7252 KB Output is correct
45 Correct 4 ms 7380 KB Output is correct
46 Correct 4 ms 7284 KB Output is correct
47 Correct 5 ms 7376 KB Output is correct
48 Correct 4 ms 7252 KB Output is correct
49 Correct 4 ms 7380 KB Output is correct
50 Correct 7 ms 7636 KB Output is correct
51 Correct 7 ms 7624 KB Output is correct
52 Correct 7 ms 7508 KB Output is correct
53 Correct 6 ms 7496 KB Output is correct
54 Correct 5 ms 7508 KB Output is correct
55 Correct 9 ms 7636 KB Output is correct
56 Correct 9 ms 7636 KB Output is correct
57 Correct 8 ms 7636 KB Output is correct
58 Correct 3 ms 7252 KB Output is correct
59 Correct 4 ms 7260 KB Output is correct
60 Correct 4 ms 7380 KB Output is correct
61 Correct 6 ms 7508 KB Output is correct
62 Correct 6 ms 7380 KB Output is correct
63 Correct 4 ms 7380 KB Output is correct
64 Correct 6 ms 7372 KB Output is correct
65 Correct 6 ms 7508 KB Output is correct
66 Correct 4 ms 7252 KB Output is correct
67 Correct 4 ms 7252 KB Output is correct
68 Correct 4 ms 7348 KB Output is correct
69 Correct 5 ms 7368 KB Output is correct
70 Correct 5 ms 7372 KB Output is correct
71 Correct 1123 ms 25508 KB Output is correct
72 Correct 712 ms 21076 KB Output is correct
73 Correct 1004 ms 23524 KB Output is correct
74 Correct 526 ms 18084 KB Output is correct
75 Correct 602 ms 18960 KB Output is correct
76 Correct 1953 ms 31892 KB Output is correct
77 Correct 1572 ms 28888 KB Output is correct
78 Correct 1436 ms 27748 KB Output is correct
79 Correct 1406 ms 27032 KB Output is correct
80 Correct 4 ms 7252 KB Output is correct
81 Correct 4 ms 7372 KB Output is correct
82 Correct 8 ms 7636 KB Output is correct
83 Correct 90 ms 10580 KB Output is correct
84 Correct 119 ms 11344 KB Output is correct
85 Correct 23 ms 8596 KB Output is correct
86 Correct 4 ms 7368 KB Output is correct
87 Correct 133 ms 12024 KB Output is correct
88 Correct 4 ms 7252 KB Output is correct
89 Correct 4 ms 7360 KB Output is correct
90 Correct 5 ms 7380 KB Output is correct
91 Correct 38 ms 9176 KB Output is correct
92 Correct 203 ms 13572 KB Output is correct
93 Execution timed out 5053 ms 74548 KB Time limit exceeded
94 Halted 0 ms 0 KB -