답안 #944241

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
944241 2024-03-12T12:19:04 Z phoenix0423 Toys (CEOI18_toy) C++17
100 / 100
1342 ms 6272 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#pragma GCC optimize("Ofast")
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define int long long
const int maxn = 2e5 + 5;
 
vector<int> factorize(int n){
    vector<int> p;
    for(int i = 1; i <= sqrt(n); i++){
        if(n % i == 0){
            if(i != 1) p.pb(i);
            if(i != n / i) p.pb(n / i);
        }
    }
    sort(p.begin(), p.end());
    return p;
}
 
signed main(void){
    fastio;
    int n;
    cin>>n;
    vector<int> p = factorize(n);
    map<int, vector<int>> mp;
    for(auto x : p) mp[x] = factorize(x);
    set<int> ans;
    auto dfs = [&](auto dfs, int cur, int lst, int cnt) -> void{
        if(cur == n){
            ans.insert(cnt);
            return;
        }
        auto v = mp[n / cur];
        int st = lower_bound(v.begin(), v.end(), lst) - v.begin();
        for(int i = st; i < v.size(); i++){
            dfs(dfs, cur * v[i], v[i], cnt + v[i] - 1);
        }
    };
    dfs(dfs, 1, 1, 0);
    cout<<ans.size()<<"\n";
    for(auto x : ans) cout<<x<<" ";
    cout<<"\n";
}

Compilation message

toy.cpp: In lambda function:
toy.cpp:41:27: 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]
   41 |         for(int i = st; i < v.size(); i++){
      |                         ~~^~~~~~~~~~
toy.cpp: In instantiation of 'main()::<lambda(auto:23, long long int, long long int, long long int)> [with auto:23 = main()::<lambda(auto:23, long long int, long long int, long long int)>]':
toy.cpp:45:21:   required from here
toy.cpp:41:27: 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]
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 352 KB Output is correct
5 Correct 0 ms 356 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 448 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 452 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 352 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 352 KB Output is correct
5 Correct 0 ms 356 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 448 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 452 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 352 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 452 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 352 KB Output is correct
5 Correct 0 ms 356 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 448 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 452 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 352 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 452 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 3 ms 456 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 2 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 2 ms 344 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 1 ms 344 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 1 ms 352 KB Output is correct
64 Correct 1 ms 348 KB Output is correct
65 Correct 1 ms 348 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 0 ms 452 KB Output is correct
68 Correct 1 ms 348 KB Output is correct
69 Correct 0 ms 460 KB Output is correct
70 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 352 KB Output is correct
5 Correct 0 ms 356 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 448 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 452 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 352 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 452 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 3 ms 456 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 2 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 2 ms 344 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 1 ms 344 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 1 ms 352 KB Output is correct
64 Correct 1 ms 348 KB Output is correct
65 Correct 1 ms 348 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 0 ms 452 KB Output is correct
68 Correct 1 ms 348 KB Output is correct
69 Correct 0 ms 460 KB Output is correct
70 Correct 1 ms 344 KB Output is correct
71 Correct 103 ms 2156 KB Output is correct
72 Correct 64 ms 1876 KB Output is correct
73 Correct 120 ms 1872 KB Output is correct
74 Correct 65 ms 1616 KB Output is correct
75 Correct 72 ms 1424 KB Output is correct
76 Correct 229 ms 2352 KB Output is correct
77 Correct 266 ms 2176 KB Output is correct
78 Correct 184 ms 2128 KB Output is correct
79 Correct 177 ms 1964 KB Output is correct
80 Correct 1 ms 348 KB Output is correct
81 Correct 1 ms 460 KB Output is correct
82 Correct 1 ms 600 KB Output is correct
83 Correct 25 ms 672 KB Output is correct
84 Correct 27 ms 860 KB Output is correct
85 Correct 5 ms 604 KB Output is correct
86 Correct 1 ms 460 KB Output is correct
87 Correct 19 ms 980 KB Output is correct
88 Correct 1 ms 348 KB Output is correct
89 Correct 0 ms 344 KB Output is correct
90 Correct 1 ms 348 KB Output is correct
91 Correct 6 ms 604 KB Output is correct
92 Correct 18 ms 1224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 460 KB Output is correct
4 Correct 0 ms 352 KB Output is correct
5 Correct 0 ms 356 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 448 KB Output is correct
14 Correct 3 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 452 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 1 ms 352 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 0 ms 452 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 1 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 1 ms 344 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 344 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 0 ms 344 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 1 ms 348 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 3 ms 456 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 2 ms 348 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 2 ms 344 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 1 ms 344 KB Output is correct
60 Correct 1 ms 348 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 1 ms 352 KB Output is correct
64 Correct 1 ms 348 KB Output is correct
65 Correct 1 ms 348 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 0 ms 452 KB Output is correct
68 Correct 1 ms 348 KB Output is correct
69 Correct 0 ms 460 KB Output is correct
70 Correct 1 ms 344 KB Output is correct
71 Correct 103 ms 2156 KB Output is correct
72 Correct 64 ms 1876 KB Output is correct
73 Correct 120 ms 1872 KB Output is correct
74 Correct 65 ms 1616 KB Output is correct
75 Correct 72 ms 1424 KB Output is correct
76 Correct 229 ms 2352 KB Output is correct
77 Correct 266 ms 2176 KB Output is correct
78 Correct 184 ms 2128 KB Output is correct
79 Correct 177 ms 1964 KB Output is correct
80 Correct 1 ms 348 KB Output is correct
81 Correct 1 ms 460 KB Output is correct
82 Correct 1 ms 600 KB Output is correct
83 Correct 25 ms 672 KB Output is correct
84 Correct 27 ms 860 KB Output is correct
85 Correct 5 ms 604 KB Output is correct
86 Correct 1 ms 460 KB Output is correct
87 Correct 19 ms 980 KB Output is correct
88 Correct 1 ms 348 KB Output is correct
89 Correct 0 ms 344 KB Output is correct
90 Correct 1 ms 348 KB Output is correct
91 Correct 6 ms 604 KB Output is correct
92 Correct 18 ms 1224 KB Output is correct
93 Correct 870 ms 5716 KB Output is correct
94 Correct 326 ms 4476 KB Output is correct
95 Correct 479 ms 4608 KB Output is correct
96 Correct 408 ms 4176 KB Output is correct
97 Correct 410 ms 3668 KB Output is correct
98 Correct 1073 ms 6272 KB Output is correct
99 Correct 1280 ms 6036 KB Output is correct
100 Correct 1083 ms 6228 KB Output is correct
101 Correct 1342 ms 5568 KB Output is correct
102 Correct 1114 ms 5016 KB Output is correct
103 Correct 552 ms 4944 KB Output is correct
104 Correct 1 ms 348 KB Output is correct
105 Correct 1 ms 348 KB Output is correct
106 Correct 2 ms 348 KB Output is correct
107 Correct 78 ms 1656 KB Output is correct
108 Correct 171 ms 2132 KB Output is correct
109 Correct 9 ms 860 KB Output is correct
110 Correct 1 ms 348 KB Output is correct
111 Correct 61 ms 1632 KB Output is correct
112 Correct 2 ms 344 KB Output is correct
113 Correct 1 ms 348 KB Output is correct
114 Correct 3 ms 612 KB Output is correct
115 Correct 1 ms 348 KB Output is correct
116 Correct 5 ms 604 KB Output is correct
117 Correct 84 ms 3024 KB Output is correct