답안 #481193

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
481193 2021-10-19T18:35:31 Z hidden1 Toys (CEOI18_toy) C++14
100 / 100
2729 ms 86608 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#ifndef LOCAL
#define cerr if(false) cerr
#endif
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(ll i = 0; i < n; i ++)
#define revn(i, n) for(ll i = n - 1; i >= 0; i --)
typedef long long ll;
template<class T, template<class T2, class A=allocator<T2> > class cont> inline ostream &operator <<(ostream &out, const cont<T> &x) { for(const auto &it : x) { out << it << " ";} return out;}
template<class T, template<class T2, class A=allocator<T2> > class cont> inline istream &operator >>(istream &in, cont<T> &x) { for(auto &it : x) { in >> it;} return in;}
template<class T, class T2> inline ostream &operator <<(ostream &out, const pair<T, T2> &x) { out << x.first << " " << x.second; return out;}
template<class T, class T2> inline istream &operator >>(istream &in, pair<T, T2> &x) { in >> x.first >> x.second; return in;}
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;

const ll MAX_N = 4e6 + 10, MAX_CORD = 2e3 + 10;
ll n;
vector<ll> divis;

void comp(ll x) {
    for(ll i = 1; i * i <= x; i ++) {
        if(x % i == 0) {
            divis.push_back(i);
            if(i * i != x) {
                divis.push_back(x / i);
            }
        }
    }

    sort(all(divis));
}

set<int> dp[MAX_CORD];
ll who[MAX_CORD][MAX_CORD];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    cin >> n;
    if(n == 1) {
        cout << 1 << endl << 0 << endl;
        return 0;
    }

    comp(n);

    dp[0].insert(0);

    forn(i, divis.size()) {
        forn(j, i + 1) {
            if(divis[i] % divis[j] != 0) {
                continue;
            }
            for(auto it : dp[j]) {
                dp[i].insert(it + divis[i] / divis[j] - 1);
            }
        }
    }

    cout << dp[divis.size() - 1].size() << endl;
    for(auto it : dp[divis.size() - 1]) {
        cout << it << " ";
    }
    cout << endl;

    return 0;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:10:36: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 | #define forn(i, n) for(ll i = 0; i < n; i ++)
......
   54 |     forn(i, divis.size()) {
      |          ~~~~~~~~~~~~~~~            
toy.cpp:54:5: note: in expansion of macro 'forn'
   54 |     forn(i, divis.size()) {
      |     ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 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 1 ms 460 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
33 Correct 1 ms 432 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 460 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 460 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 0 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 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 1 ms 460 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
33 Correct 1 ms 432 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 460 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 460 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 0 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 3 ms 588 KB Output is correct
51 Correct 3 ms 588 KB Output is correct
52 Correct 3 ms 588 KB Output is correct
53 Correct 3 ms 588 KB Output is correct
54 Correct 1 ms 460 KB Output is correct
55 Correct 5 ms 716 KB Output is correct
56 Correct 5 ms 716 KB Output is correct
57 Correct 4 ms 716 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 332 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 2 ms 588 KB Output is correct
62 Correct 1 ms 460 KB Output is correct
63 Correct 1 ms 460 KB Output is correct
64 Correct 1 ms 460 KB Output is correct
65 Correct 2 ms 588 KB Output is correct
66 Correct 1 ms 332 KB Output is correct
67 Correct 1 ms 332 KB Output is correct
68 Correct 1 ms 332 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 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 1 ms 460 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
33 Correct 1 ms 432 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 460 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 460 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 0 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 3 ms 588 KB Output is correct
51 Correct 3 ms 588 KB Output is correct
52 Correct 3 ms 588 KB Output is correct
53 Correct 3 ms 588 KB Output is correct
54 Correct 1 ms 460 KB Output is correct
55 Correct 5 ms 716 KB Output is correct
56 Correct 5 ms 716 KB Output is correct
57 Correct 4 ms 716 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 332 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 2 ms 588 KB Output is correct
62 Correct 1 ms 460 KB Output is correct
63 Correct 1 ms 460 KB Output is correct
64 Correct 1 ms 460 KB Output is correct
65 Correct 2 ms 588 KB Output is correct
66 Correct 1 ms 332 KB Output is correct
67 Correct 1 ms 332 KB Output is correct
68 Correct 1 ms 332 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 1 ms 460 KB Output is correct
71 Correct 386 ms 18540 KB Output is correct
72 Correct 282 ms 14096 KB Output is correct
73 Correct 356 ms 16532 KB Output is correct
74 Correct 201 ms 11180 KB Output is correct
75 Correct 231 ms 11844 KB Output is correct
76 Correct 608 ms 24976 KB Output is correct
77 Correct 549 ms 21864 KB Output is correct
78 Correct 472 ms 20752 KB Output is correct
79 Correct 451 ms 19980 KB Output is correct
80 Correct 1 ms 332 KB Output is correct
81 Correct 1 ms 332 KB Output is correct
82 Correct 3 ms 716 KB Output is correct
83 Correct 50 ms 3652 KB Output is correct
84 Correct 75 ms 4392 KB Output is correct
85 Correct 14 ms 1612 KB Output is correct
86 Correct 1 ms 332 KB Output is correct
87 Correct 69 ms 5060 KB Output is correct
88 Correct 1 ms 416 KB Output is correct
89 Correct 1 ms 332 KB Output is correct
90 Correct 1 ms 332 KB Output is correct
91 Correct 22 ms 2124 KB Output is correct
92 Correct 87 ms 6596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 332 KB Output is correct
18 Correct 0 ms 332 KB Output is correct
19 Correct 0 ms 332 KB Output is correct
20 Correct 0 ms 332 KB Output is correct
21 Correct 0 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 0 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 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 1 ms 460 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
33 Correct 1 ms 432 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 332 KB Output is correct
37 Correct 1 ms 460 KB Output is correct
38 Correct 1 ms 332 KB Output is correct
39 Correct 1 ms 332 KB Output is correct
40 Correct 1 ms 460 KB Output is correct
41 Correct 1 ms 332 KB Output is correct
42 Correct 1 ms 332 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 0 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 3 ms 588 KB Output is correct
51 Correct 3 ms 588 KB Output is correct
52 Correct 3 ms 588 KB Output is correct
53 Correct 3 ms 588 KB Output is correct
54 Correct 1 ms 460 KB Output is correct
55 Correct 5 ms 716 KB Output is correct
56 Correct 5 ms 716 KB Output is correct
57 Correct 4 ms 716 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 1 ms 332 KB Output is correct
60 Correct 1 ms 332 KB Output is correct
61 Correct 2 ms 588 KB Output is correct
62 Correct 1 ms 460 KB Output is correct
63 Correct 1 ms 460 KB Output is correct
64 Correct 1 ms 460 KB Output is correct
65 Correct 2 ms 588 KB Output is correct
66 Correct 1 ms 332 KB Output is correct
67 Correct 1 ms 332 KB Output is correct
68 Correct 1 ms 332 KB Output is correct
69 Correct 1 ms 332 KB Output is correct
70 Correct 1 ms 460 KB Output is correct
71 Correct 386 ms 18540 KB Output is correct
72 Correct 282 ms 14096 KB Output is correct
73 Correct 356 ms 16532 KB Output is correct
74 Correct 201 ms 11180 KB Output is correct
75 Correct 231 ms 11844 KB Output is correct
76 Correct 608 ms 24976 KB Output is correct
77 Correct 549 ms 21864 KB Output is correct
78 Correct 472 ms 20752 KB Output is correct
79 Correct 451 ms 19980 KB Output is correct
80 Correct 1 ms 332 KB Output is correct
81 Correct 1 ms 332 KB Output is correct
82 Correct 3 ms 716 KB Output is correct
83 Correct 50 ms 3652 KB Output is correct
84 Correct 75 ms 4392 KB Output is correct
85 Correct 14 ms 1612 KB Output is correct
86 Correct 1 ms 332 KB Output is correct
87 Correct 69 ms 5060 KB Output is correct
88 Correct 1 ms 416 KB Output is correct
89 Correct 1 ms 332 KB Output is correct
90 Correct 1 ms 332 KB Output is correct
91 Correct 22 ms 2124 KB Output is correct
92 Correct 87 ms 6596 KB Output is correct
93 Correct 2295 ms 77212 KB Output is correct
94 Correct 1266 ms 52080 KB Output is correct
95 Correct 1421 ms 54600 KB Output is correct
96 Correct 1295 ms 48876 KB Output is correct
97 Correct 1160 ms 44424 KB Output is correct
98 Correct 2598 ms 85324 KB Output is correct
99 Correct 2729 ms 86608 KB Output is correct
100 Correct 2538 ms 83436 KB Output is correct
101 Correct 2419 ms 77128 KB Output is correct
102 Correct 2125 ms 69492 KB Output is correct
103 Correct 1697 ms 62340 KB Output is correct
104 Correct 1 ms 344 KB Output is correct
105 Correct 1 ms 332 KB Output is correct
106 Correct 6 ms 972 KB Output is correct
107 Correct 170 ms 9616 KB Output is correct
108 Correct 441 ms 20388 KB Output is correct
109 Correct 37 ms 3276 KB Output is correct
110 Correct 1 ms 332 KB Output is correct
111 Correct 214 ms 12184 KB Output is correct
112 Correct 1 ms 332 KB Output is correct
113 Correct 1 ms 332 KB Output is correct
114 Correct 6 ms 972 KB Output is correct
115 Correct 1 ms 332 KB Output is correct
116 Correct 13 ms 1672 KB Output is correct
117 Correct 425 ms 24468 KB Output is correct