# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
481188 |
2021-10-19T18:22:15 Z |
hidden1 |
Toys (CEOI18_toy) |
C++14 |
|
402 ms |
262148 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));
}
bitset<MAX_N> 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][0] = true;
forn(i, divis.size() - 1) {
cerr << "Starting " << i << ": ";
forn(j, MAX_N) {
if(dp[i][j]) {
cerr << j << " ";
}
}
cerr << endl;
forn(j, divis.size() - 1) {
ll prod = divis[i] * divis[j];
ll to = -1;
if(n % prod == 0) {
to = lower_bound(all(divis), prod) - divis.begin();
} else {
continue;
}
cerr << "from " << divis[i] << " " << divis[j] << " -> " << divis[to] << endl;
dp[to] |= dp[i] << (divis[j] - 1);
}
}
cout << dp[divis.size() - 1].count() + 1 << endl;
forn(i, MAX_N) {
if(dp[divis.size() - 1][i]) {
cout << i << " ";
}
}
cout << n - 1 << 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() - 1) {
| ~~~~~~~~~~~~~~~~~~~
toy.cpp:54:5: note: in expansion of macro 'forn'
54 | forn(i, divis.size() - 1) {
| ^~~~
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 ++)
......
62 | forn(j, divis.size() - 1) {
| ~~~~~~~~~~~~~~~~~~~
toy.cpp:62:9: note: in expansion of macro 'forn'
62 | forn(j, divis.size() - 1) {
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1228 KB |
Output is correct |
2 |
Correct |
9 ms |
1868 KB |
Output is correct |
3 |
Correct |
9 ms |
1740 KB |
Output is correct |
4 |
Correct |
10 ms |
2764 KB |
Output is correct |
5 |
Correct |
8 ms |
1788 KB |
Output is correct |
6 |
Correct |
12 ms |
3148 KB |
Output is correct |
7 |
Correct |
8 ms |
1740 KB |
Output is correct |
8 |
Correct |
13 ms |
3256 KB |
Output is correct |
9 |
Correct |
9 ms |
2776 KB |
Output is correct |
10 |
Correct |
9 ms |
3188 KB |
Output is correct |
11 |
Correct |
11 ms |
1740 KB |
Output is correct |
12 |
Correct |
11 ms |
4172 KB |
Output is correct |
13 |
Correct |
8 ms |
1740 KB |
Output is correct |
14 |
Correct |
10 ms |
3148 KB |
Output is correct |
15 |
Correct |
9 ms |
3148 KB |
Output is correct |
16 |
Correct |
11 ms |
3660 KB |
Output is correct |
17 |
Correct |
8 ms |
1740 KB |
Output is correct |
18 |
Correct |
10 ms |
4228 KB |
Output is correct |
19 |
Correct |
8 ms |
1740 KB |
Output is correct |
20 |
Correct |
15 ms |
4172 KB |
Output is correct |
21 |
Correct |
10 ms |
4172 KB |
Output is correct |
22 |
Correct |
18 ms |
5208 KB |
Output is correct |
23 |
Correct |
10 ms |
2772 KB |
Output is correct |
24 |
Correct |
15 ms |
6188 KB |
Output is correct |
25 |
Correct |
13 ms |
5700 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1228 KB |
Output is correct |
2 |
Correct |
9 ms |
1868 KB |
Output is correct |
3 |
Correct |
9 ms |
1740 KB |
Output is correct |
4 |
Correct |
10 ms |
2764 KB |
Output is correct |
5 |
Correct |
8 ms |
1788 KB |
Output is correct |
6 |
Correct |
12 ms |
3148 KB |
Output is correct |
7 |
Correct |
8 ms |
1740 KB |
Output is correct |
8 |
Correct |
13 ms |
3256 KB |
Output is correct |
9 |
Correct |
9 ms |
2776 KB |
Output is correct |
10 |
Correct |
9 ms |
3188 KB |
Output is correct |
11 |
Correct |
11 ms |
1740 KB |
Output is correct |
12 |
Correct |
11 ms |
4172 KB |
Output is correct |
13 |
Correct |
8 ms |
1740 KB |
Output is correct |
14 |
Correct |
10 ms |
3148 KB |
Output is correct |
15 |
Correct |
9 ms |
3148 KB |
Output is correct |
16 |
Correct |
11 ms |
3660 KB |
Output is correct |
17 |
Correct |
8 ms |
1740 KB |
Output is correct |
18 |
Correct |
10 ms |
4228 KB |
Output is correct |
19 |
Correct |
8 ms |
1740 KB |
Output is correct |
20 |
Correct |
15 ms |
4172 KB |
Output is correct |
21 |
Correct |
10 ms |
4172 KB |
Output is correct |
22 |
Correct |
18 ms |
5208 KB |
Output is correct |
23 |
Correct |
10 ms |
2772 KB |
Output is correct |
24 |
Correct |
15 ms |
6188 KB |
Output is correct |
25 |
Correct |
13 ms |
5700 KB |
Output is correct |
26 |
Correct |
142 ms |
32520 KB |
Output is correct |
27 |
Correct |
141 ms |
30540 KB |
Output is correct |
28 |
Correct |
109 ms |
24772 KB |
Output is correct |
29 |
Correct |
71 ms |
20880 KB |
Output is correct |
30 |
Correct |
58 ms |
18892 KB |
Output is correct |
31 |
Correct |
136 ms |
28672 KB |
Output is correct |
32 |
Correct |
118 ms |
27600 KB |
Output is correct |
33 |
Correct |
123 ms |
28672 KB |
Output is correct |
34 |
Correct |
8 ms |
1740 KB |
Output is correct |
35 |
Correct |
10 ms |
3252 KB |
Output is correct |
36 |
Correct |
22 ms |
8148 KB |
Output is correct |
37 |
Correct |
79 ms |
18896 KB |
Output is correct |
38 |
Correct |
44 ms |
13524 KB |
Output is correct |
39 |
Correct |
16 ms |
7116 KB |
Output is correct |
40 |
Correct |
99 ms |
24760 KB |
Output is correct |
41 |
Correct |
8 ms |
1740 KB |
Output is correct |
42 |
Correct |
8 ms |
1740 KB |
Output is correct |
43 |
Correct |
37 ms |
13004 KB |
Output is correct |
44 |
Correct |
10 ms |
3148 KB |
Output is correct |
45 |
Correct |
59 ms |
18900 KB |
Output is correct |
46 |
Correct |
17 ms |
7168 KB |
Output is correct |
47 |
Correct |
78 ms |
18792 KB |
Output is correct |
48 |
Correct |
11 ms |
4232 KB |
Output is correct |
49 |
Correct |
52 ms |
16932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1228 KB |
Output is correct |
2 |
Correct |
9 ms |
1868 KB |
Output is correct |
3 |
Correct |
9 ms |
1740 KB |
Output is correct |
4 |
Correct |
10 ms |
2764 KB |
Output is correct |
5 |
Correct |
8 ms |
1788 KB |
Output is correct |
6 |
Correct |
12 ms |
3148 KB |
Output is correct |
7 |
Correct |
8 ms |
1740 KB |
Output is correct |
8 |
Correct |
13 ms |
3256 KB |
Output is correct |
9 |
Correct |
9 ms |
2776 KB |
Output is correct |
10 |
Correct |
9 ms |
3188 KB |
Output is correct |
11 |
Correct |
11 ms |
1740 KB |
Output is correct |
12 |
Correct |
11 ms |
4172 KB |
Output is correct |
13 |
Correct |
8 ms |
1740 KB |
Output is correct |
14 |
Correct |
10 ms |
3148 KB |
Output is correct |
15 |
Correct |
9 ms |
3148 KB |
Output is correct |
16 |
Correct |
11 ms |
3660 KB |
Output is correct |
17 |
Correct |
8 ms |
1740 KB |
Output is correct |
18 |
Correct |
10 ms |
4228 KB |
Output is correct |
19 |
Correct |
8 ms |
1740 KB |
Output is correct |
20 |
Correct |
15 ms |
4172 KB |
Output is correct |
21 |
Correct |
10 ms |
4172 KB |
Output is correct |
22 |
Correct |
18 ms |
5208 KB |
Output is correct |
23 |
Correct |
10 ms |
2772 KB |
Output is correct |
24 |
Correct |
15 ms |
6188 KB |
Output is correct |
25 |
Correct |
13 ms |
5700 KB |
Output is correct |
26 |
Correct |
142 ms |
32520 KB |
Output is correct |
27 |
Correct |
141 ms |
30540 KB |
Output is correct |
28 |
Correct |
109 ms |
24772 KB |
Output is correct |
29 |
Correct |
71 ms |
20880 KB |
Output is correct |
30 |
Correct |
58 ms |
18892 KB |
Output is correct |
31 |
Correct |
136 ms |
28672 KB |
Output is correct |
32 |
Correct |
118 ms |
27600 KB |
Output is correct |
33 |
Correct |
123 ms |
28672 KB |
Output is correct |
34 |
Correct |
8 ms |
1740 KB |
Output is correct |
35 |
Correct |
10 ms |
3252 KB |
Output is correct |
36 |
Correct |
22 ms |
8148 KB |
Output is correct |
37 |
Correct |
79 ms |
18896 KB |
Output is correct |
38 |
Correct |
44 ms |
13524 KB |
Output is correct |
39 |
Correct |
16 ms |
7116 KB |
Output is correct |
40 |
Correct |
99 ms |
24760 KB |
Output is correct |
41 |
Correct |
8 ms |
1740 KB |
Output is correct |
42 |
Correct |
8 ms |
1740 KB |
Output is correct |
43 |
Correct |
37 ms |
13004 KB |
Output is correct |
44 |
Correct |
10 ms |
3148 KB |
Output is correct |
45 |
Correct |
59 ms |
18900 KB |
Output is correct |
46 |
Correct |
17 ms |
7168 KB |
Output is correct |
47 |
Correct |
78 ms |
18792 KB |
Output is correct |
48 |
Correct |
11 ms |
4232 KB |
Output is correct |
49 |
Correct |
52 ms |
16932 KB |
Output is correct |
50 |
Correct |
377 ms |
63904 KB |
Output is correct |
51 |
Correct |
344 ms |
59912 KB |
Output is correct |
52 |
Correct |
314 ms |
54172 KB |
Output is correct |
53 |
Correct |
341 ms |
50196 KB |
Output is correct |
54 |
Correct |
229 ms |
48168 KB |
Output is correct |
55 |
Correct |
402 ms |
59988 KB |
Output is correct |
56 |
Correct |
342 ms |
54084 KB |
Output is correct |
57 |
Correct |
394 ms |
60060 KB |
Output is correct |
58 |
Correct |
8 ms |
1784 KB |
Output is correct |
59 |
Correct |
12 ms |
3148 KB |
Output is correct |
60 |
Correct |
31 ms |
9592 KB |
Output is correct |
61 |
Correct |
168 ms |
28668 KB |
Output is correct |
62 |
Correct |
161 ms |
32588 KB |
Output is correct |
63 |
Correct |
76 ms |
18892 KB |
Output is correct |
64 |
Correct |
17 ms |
7172 KB |
Output is correct |
65 |
Correct |
202 ms |
37940 KB |
Output is correct |
66 |
Correct |
9 ms |
3148 KB |
Output is correct |
67 |
Correct |
10 ms |
4232 KB |
Output is correct |
68 |
Correct |
33 ms |
13032 KB |
Output is correct |
69 |
Correct |
77 ms |
24760 KB |
Output is correct |
70 |
Correct |
215 ms |
48248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1228 KB |
Output is correct |
2 |
Correct |
9 ms |
1868 KB |
Output is correct |
3 |
Correct |
9 ms |
1740 KB |
Output is correct |
4 |
Correct |
10 ms |
2764 KB |
Output is correct |
5 |
Correct |
8 ms |
1788 KB |
Output is correct |
6 |
Correct |
12 ms |
3148 KB |
Output is correct |
7 |
Correct |
8 ms |
1740 KB |
Output is correct |
8 |
Correct |
13 ms |
3256 KB |
Output is correct |
9 |
Correct |
9 ms |
2776 KB |
Output is correct |
10 |
Correct |
9 ms |
3188 KB |
Output is correct |
11 |
Correct |
11 ms |
1740 KB |
Output is correct |
12 |
Correct |
11 ms |
4172 KB |
Output is correct |
13 |
Correct |
8 ms |
1740 KB |
Output is correct |
14 |
Correct |
10 ms |
3148 KB |
Output is correct |
15 |
Correct |
9 ms |
3148 KB |
Output is correct |
16 |
Correct |
11 ms |
3660 KB |
Output is correct |
17 |
Correct |
8 ms |
1740 KB |
Output is correct |
18 |
Correct |
10 ms |
4228 KB |
Output is correct |
19 |
Correct |
8 ms |
1740 KB |
Output is correct |
20 |
Correct |
15 ms |
4172 KB |
Output is correct |
21 |
Correct |
10 ms |
4172 KB |
Output is correct |
22 |
Correct |
18 ms |
5208 KB |
Output is correct |
23 |
Correct |
10 ms |
2772 KB |
Output is correct |
24 |
Correct |
15 ms |
6188 KB |
Output is correct |
25 |
Correct |
13 ms |
5700 KB |
Output is correct |
26 |
Correct |
142 ms |
32520 KB |
Output is correct |
27 |
Correct |
141 ms |
30540 KB |
Output is correct |
28 |
Correct |
109 ms |
24772 KB |
Output is correct |
29 |
Correct |
71 ms |
20880 KB |
Output is correct |
30 |
Correct |
58 ms |
18892 KB |
Output is correct |
31 |
Correct |
136 ms |
28672 KB |
Output is correct |
32 |
Correct |
118 ms |
27600 KB |
Output is correct |
33 |
Correct |
123 ms |
28672 KB |
Output is correct |
34 |
Correct |
8 ms |
1740 KB |
Output is correct |
35 |
Correct |
10 ms |
3252 KB |
Output is correct |
36 |
Correct |
22 ms |
8148 KB |
Output is correct |
37 |
Correct |
79 ms |
18896 KB |
Output is correct |
38 |
Correct |
44 ms |
13524 KB |
Output is correct |
39 |
Correct |
16 ms |
7116 KB |
Output is correct |
40 |
Correct |
99 ms |
24760 KB |
Output is correct |
41 |
Correct |
8 ms |
1740 KB |
Output is correct |
42 |
Correct |
8 ms |
1740 KB |
Output is correct |
43 |
Correct |
37 ms |
13004 KB |
Output is correct |
44 |
Correct |
10 ms |
3148 KB |
Output is correct |
45 |
Correct |
59 ms |
18900 KB |
Output is correct |
46 |
Correct |
17 ms |
7168 KB |
Output is correct |
47 |
Correct |
78 ms |
18792 KB |
Output is correct |
48 |
Correct |
11 ms |
4232 KB |
Output is correct |
49 |
Correct |
52 ms |
16932 KB |
Output is correct |
50 |
Correct |
377 ms |
63904 KB |
Output is correct |
51 |
Correct |
344 ms |
59912 KB |
Output is correct |
52 |
Correct |
314 ms |
54172 KB |
Output is correct |
53 |
Correct |
341 ms |
50196 KB |
Output is correct |
54 |
Correct |
229 ms |
48168 KB |
Output is correct |
55 |
Correct |
402 ms |
59988 KB |
Output is correct |
56 |
Correct |
342 ms |
54084 KB |
Output is correct |
57 |
Correct |
394 ms |
60060 KB |
Output is correct |
58 |
Correct |
8 ms |
1784 KB |
Output is correct |
59 |
Correct |
12 ms |
3148 KB |
Output is correct |
60 |
Correct |
31 ms |
9592 KB |
Output is correct |
61 |
Correct |
168 ms |
28668 KB |
Output is correct |
62 |
Correct |
161 ms |
32588 KB |
Output is correct |
63 |
Correct |
76 ms |
18892 KB |
Output is correct |
64 |
Correct |
17 ms |
7172 KB |
Output is correct |
65 |
Correct |
202 ms |
37940 KB |
Output is correct |
66 |
Correct |
9 ms |
3148 KB |
Output is correct |
67 |
Correct |
10 ms |
4232 KB |
Output is correct |
68 |
Correct |
33 ms |
13032 KB |
Output is correct |
69 |
Correct |
77 ms |
24760 KB |
Output is correct |
70 |
Correct |
215 ms |
48248 KB |
Output is correct |
71 |
Runtime error |
222 ms |
262148 KB |
Execution killed with signal 9 |
72 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1228 KB |
Output is correct |
2 |
Correct |
9 ms |
1868 KB |
Output is correct |
3 |
Correct |
9 ms |
1740 KB |
Output is correct |
4 |
Correct |
10 ms |
2764 KB |
Output is correct |
5 |
Correct |
8 ms |
1788 KB |
Output is correct |
6 |
Correct |
12 ms |
3148 KB |
Output is correct |
7 |
Correct |
8 ms |
1740 KB |
Output is correct |
8 |
Correct |
13 ms |
3256 KB |
Output is correct |
9 |
Correct |
9 ms |
2776 KB |
Output is correct |
10 |
Correct |
9 ms |
3188 KB |
Output is correct |
11 |
Correct |
11 ms |
1740 KB |
Output is correct |
12 |
Correct |
11 ms |
4172 KB |
Output is correct |
13 |
Correct |
8 ms |
1740 KB |
Output is correct |
14 |
Correct |
10 ms |
3148 KB |
Output is correct |
15 |
Correct |
9 ms |
3148 KB |
Output is correct |
16 |
Correct |
11 ms |
3660 KB |
Output is correct |
17 |
Correct |
8 ms |
1740 KB |
Output is correct |
18 |
Correct |
10 ms |
4228 KB |
Output is correct |
19 |
Correct |
8 ms |
1740 KB |
Output is correct |
20 |
Correct |
15 ms |
4172 KB |
Output is correct |
21 |
Correct |
10 ms |
4172 KB |
Output is correct |
22 |
Correct |
18 ms |
5208 KB |
Output is correct |
23 |
Correct |
10 ms |
2772 KB |
Output is correct |
24 |
Correct |
15 ms |
6188 KB |
Output is correct |
25 |
Correct |
13 ms |
5700 KB |
Output is correct |
26 |
Correct |
142 ms |
32520 KB |
Output is correct |
27 |
Correct |
141 ms |
30540 KB |
Output is correct |
28 |
Correct |
109 ms |
24772 KB |
Output is correct |
29 |
Correct |
71 ms |
20880 KB |
Output is correct |
30 |
Correct |
58 ms |
18892 KB |
Output is correct |
31 |
Correct |
136 ms |
28672 KB |
Output is correct |
32 |
Correct |
118 ms |
27600 KB |
Output is correct |
33 |
Correct |
123 ms |
28672 KB |
Output is correct |
34 |
Correct |
8 ms |
1740 KB |
Output is correct |
35 |
Correct |
10 ms |
3252 KB |
Output is correct |
36 |
Correct |
22 ms |
8148 KB |
Output is correct |
37 |
Correct |
79 ms |
18896 KB |
Output is correct |
38 |
Correct |
44 ms |
13524 KB |
Output is correct |
39 |
Correct |
16 ms |
7116 KB |
Output is correct |
40 |
Correct |
99 ms |
24760 KB |
Output is correct |
41 |
Correct |
8 ms |
1740 KB |
Output is correct |
42 |
Correct |
8 ms |
1740 KB |
Output is correct |
43 |
Correct |
37 ms |
13004 KB |
Output is correct |
44 |
Correct |
10 ms |
3148 KB |
Output is correct |
45 |
Correct |
59 ms |
18900 KB |
Output is correct |
46 |
Correct |
17 ms |
7168 KB |
Output is correct |
47 |
Correct |
78 ms |
18792 KB |
Output is correct |
48 |
Correct |
11 ms |
4232 KB |
Output is correct |
49 |
Correct |
52 ms |
16932 KB |
Output is correct |
50 |
Correct |
377 ms |
63904 KB |
Output is correct |
51 |
Correct |
344 ms |
59912 KB |
Output is correct |
52 |
Correct |
314 ms |
54172 KB |
Output is correct |
53 |
Correct |
341 ms |
50196 KB |
Output is correct |
54 |
Correct |
229 ms |
48168 KB |
Output is correct |
55 |
Correct |
402 ms |
59988 KB |
Output is correct |
56 |
Correct |
342 ms |
54084 KB |
Output is correct |
57 |
Correct |
394 ms |
60060 KB |
Output is correct |
58 |
Correct |
8 ms |
1784 KB |
Output is correct |
59 |
Correct |
12 ms |
3148 KB |
Output is correct |
60 |
Correct |
31 ms |
9592 KB |
Output is correct |
61 |
Correct |
168 ms |
28668 KB |
Output is correct |
62 |
Correct |
161 ms |
32588 KB |
Output is correct |
63 |
Correct |
76 ms |
18892 KB |
Output is correct |
64 |
Correct |
17 ms |
7172 KB |
Output is correct |
65 |
Correct |
202 ms |
37940 KB |
Output is correct |
66 |
Correct |
9 ms |
3148 KB |
Output is correct |
67 |
Correct |
10 ms |
4232 KB |
Output is correct |
68 |
Correct |
33 ms |
13032 KB |
Output is correct |
69 |
Correct |
77 ms |
24760 KB |
Output is correct |
70 |
Correct |
215 ms |
48248 KB |
Output is correct |
71 |
Runtime error |
222 ms |
262148 KB |
Execution killed with signal 9 |
72 |
Halted |
0 ms |
0 KB |
- |