답안 #1032024

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1032024 2024-07-23T10:17:50 Z NValchanov Toys (CEOI18_toy) C++17
100 / 100
2870 ms 117072 KB
#include <bits/stdc++.h>

#define endl '\n'

using namespace std;

typedef long long ll;

const ll MAXN = 1e9 + 10;
const int SQRT = 4e4 + 10;

map < ll, bool > dp[SQRT];

ll n, m;
vector < ll > divs;

void read()
{
    cin >> n;

    if(n == 1)
    {
        cout << 1 << endl;
        cout << 0 << endl;
        exit(0);
    }
}

void fill_divs()
{
    for(ll i = 2; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            divs.push_back(i);
            if(i * i != n)
                divs.push_back(n / i);
        }
    }
    divs.push_back(1);
    divs.push_back(n);
    m = divs.size();

    sort(divs.begin(), divs.end());
}

void solve()
{
    dp[0][0] = true;

    for(int i = 0; i < m; i++)
    {
        for(int j = i + 1; j < m; j++)
        {
            if(divs[j] % divs[i] == 0)
            {
                int whole = divs[j] / divs[i];

                for(auto it : dp[i])
                {
                    dp[j][it.first + whole - 1] = true;
                }
            }
        }
    }
}

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

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    read();
    fill_divs();
    solve();
    print();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2140 KB Output is correct
2 Correct 1 ms 2140 KB Output is correct
3 Correct 1 ms 2140 KB Output is correct
4 Correct 1 ms 2140 KB Output is correct
5 Correct 1 ms 2140 KB Output is correct
6 Correct 1 ms 2140 KB Output is correct
7 Correct 1 ms 2140 KB Output is correct
8 Correct 1 ms 2140 KB Output is correct
9 Correct 1 ms 2140 KB Output is correct
10 Correct 2 ms 2120 KB Output is correct
11 Correct 1 ms 2140 KB Output is correct
12 Correct 1 ms 2140 KB Output is correct
13 Correct 1 ms 2140 KB Output is correct
14 Correct 1 ms 2140 KB Output is correct
15 Correct 1 ms 2140 KB Output is correct
16 Correct 1 ms 2140 KB Output is correct
17 Correct 1 ms 2140 KB Output is correct
18 Correct 1 ms 2140 KB Output is correct
19 Correct 1 ms 2140 KB Output is correct
20 Correct 1 ms 2140 KB Output is correct
21 Correct 1 ms 2140 KB Output is correct
22 Correct 1 ms 2140 KB Output is correct
23 Correct 1 ms 2136 KB Output is correct
24 Correct 1 ms 2140 KB Output is correct
25 Correct 1 ms 2140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2140 KB Output is correct
2 Correct 1 ms 2140 KB Output is correct
3 Correct 1 ms 2140 KB Output is correct
4 Correct 1 ms 2140 KB Output is correct
5 Correct 1 ms 2140 KB Output is correct
6 Correct 1 ms 2140 KB Output is correct
7 Correct 1 ms 2140 KB Output is correct
8 Correct 1 ms 2140 KB Output is correct
9 Correct 1 ms 2140 KB Output is correct
10 Correct 2 ms 2120 KB Output is correct
11 Correct 1 ms 2140 KB Output is correct
12 Correct 1 ms 2140 KB Output is correct
13 Correct 1 ms 2140 KB Output is correct
14 Correct 1 ms 2140 KB Output is correct
15 Correct 1 ms 2140 KB Output is correct
16 Correct 1 ms 2140 KB Output is correct
17 Correct 1 ms 2140 KB Output is correct
18 Correct 1 ms 2140 KB Output is correct
19 Correct 1 ms 2140 KB Output is correct
20 Correct 1 ms 2140 KB Output is correct
21 Correct 1 ms 2140 KB Output is correct
22 Correct 1 ms 2140 KB Output is correct
23 Correct 1 ms 2136 KB Output is correct
24 Correct 1 ms 2140 KB Output is correct
25 Correct 1 ms 2140 KB Output is correct
26 Correct 2 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2140 KB Output is correct
29 Correct 1 ms 2140 KB Output is correct
30 Correct 1 ms 2140 KB Output is correct
31 Correct 2 ms 2396 KB Output is correct
32 Correct 2 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2140 KB Output is correct
35 Correct 1 ms 2140 KB Output is correct
36 Correct 1 ms 2136 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2136 KB Output is correct
39 Correct 1 ms 2140 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 2 ms 2648 KB Output is correct
42 Correct 1 ms 2332 KB Output is correct
43 Correct 1 ms 2140 KB Output is correct
44 Correct 1 ms 2140 KB Output is correct
45 Correct 1 ms 2140 KB Output is correct
46 Correct 1 ms 2140 KB Output is correct
47 Correct 1 ms 2140 KB Output is correct
48 Correct 1 ms 2140 KB Output is correct
49 Correct 1 ms 2356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2140 KB Output is correct
2 Correct 1 ms 2140 KB Output is correct
3 Correct 1 ms 2140 KB Output is correct
4 Correct 1 ms 2140 KB Output is correct
5 Correct 1 ms 2140 KB Output is correct
6 Correct 1 ms 2140 KB Output is correct
7 Correct 1 ms 2140 KB Output is correct
8 Correct 1 ms 2140 KB Output is correct
9 Correct 1 ms 2140 KB Output is correct
10 Correct 2 ms 2120 KB Output is correct
11 Correct 1 ms 2140 KB Output is correct
12 Correct 1 ms 2140 KB Output is correct
13 Correct 1 ms 2140 KB Output is correct
14 Correct 1 ms 2140 KB Output is correct
15 Correct 1 ms 2140 KB Output is correct
16 Correct 1 ms 2140 KB Output is correct
17 Correct 1 ms 2140 KB Output is correct
18 Correct 1 ms 2140 KB Output is correct
19 Correct 1 ms 2140 KB Output is correct
20 Correct 1 ms 2140 KB Output is correct
21 Correct 1 ms 2140 KB Output is correct
22 Correct 1 ms 2140 KB Output is correct
23 Correct 1 ms 2136 KB Output is correct
24 Correct 1 ms 2140 KB Output is correct
25 Correct 1 ms 2140 KB Output is correct
26 Correct 2 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2140 KB Output is correct
29 Correct 1 ms 2140 KB Output is correct
30 Correct 1 ms 2140 KB Output is correct
31 Correct 2 ms 2396 KB Output is correct
32 Correct 2 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2140 KB Output is correct
35 Correct 1 ms 2140 KB Output is correct
36 Correct 1 ms 2136 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2136 KB Output is correct
39 Correct 1 ms 2140 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 2 ms 2648 KB Output is correct
42 Correct 1 ms 2332 KB Output is correct
43 Correct 1 ms 2140 KB Output is correct
44 Correct 1 ms 2140 KB Output is correct
45 Correct 1 ms 2140 KB Output is correct
46 Correct 1 ms 2140 KB Output is correct
47 Correct 1 ms 2140 KB Output is correct
48 Correct 1 ms 2140 KB Output is correct
49 Correct 1 ms 2356 KB Output is correct
50 Correct 3 ms 2596 KB Output is correct
51 Correct 3 ms 2652 KB Output is correct
52 Correct 3 ms 2652 KB Output is correct
53 Correct 3 ms 2396 KB Output is correct
54 Correct 2 ms 2396 KB Output is correct
55 Correct 4 ms 2652 KB Output is correct
56 Correct 4 ms 2652 KB Output is correct
57 Correct 3 ms 2724 KB Output is correct
58 Correct 1 ms 2140 KB Output is correct
59 Correct 1 ms 2140 KB Output is correct
60 Correct 1 ms 2292 KB Output is correct
61 Correct 2 ms 2396 KB Output is correct
62 Correct 2 ms 2428 KB Output is correct
63 Correct 1 ms 2396 KB Output is correct
64 Correct 1 ms 2140 KB Output is correct
65 Correct 3 ms 2396 KB Output is correct
66 Correct 1 ms 2136 KB Output is correct
67 Correct 1 ms 2140 KB Output is correct
68 Correct 1 ms 2140 KB Output is correct
69 Correct 2 ms 2140 KB Output is correct
70 Correct 2 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2140 KB Output is correct
2 Correct 1 ms 2140 KB Output is correct
3 Correct 1 ms 2140 KB Output is correct
4 Correct 1 ms 2140 KB Output is correct
5 Correct 1 ms 2140 KB Output is correct
6 Correct 1 ms 2140 KB Output is correct
7 Correct 1 ms 2140 KB Output is correct
8 Correct 1 ms 2140 KB Output is correct
9 Correct 1 ms 2140 KB Output is correct
10 Correct 2 ms 2120 KB Output is correct
11 Correct 1 ms 2140 KB Output is correct
12 Correct 1 ms 2140 KB Output is correct
13 Correct 1 ms 2140 KB Output is correct
14 Correct 1 ms 2140 KB Output is correct
15 Correct 1 ms 2140 KB Output is correct
16 Correct 1 ms 2140 KB Output is correct
17 Correct 1 ms 2140 KB Output is correct
18 Correct 1 ms 2140 KB Output is correct
19 Correct 1 ms 2140 KB Output is correct
20 Correct 1 ms 2140 KB Output is correct
21 Correct 1 ms 2140 KB Output is correct
22 Correct 1 ms 2140 KB Output is correct
23 Correct 1 ms 2136 KB Output is correct
24 Correct 1 ms 2140 KB Output is correct
25 Correct 1 ms 2140 KB Output is correct
26 Correct 2 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2140 KB Output is correct
29 Correct 1 ms 2140 KB Output is correct
30 Correct 1 ms 2140 KB Output is correct
31 Correct 2 ms 2396 KB Output is correct
32 Correct 2 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2140 KB Output is correct
35 Correct 1 ms 2140 KB Output is correct
36 Correct 1 ms 2136 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2136 KB Output is correct
39 Correct 1 ms 2140 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 2 ms 2648 KB Output is correct
42 Correct 1 ms 2332 KB Output is correct
43 Correct 1 ms 2140 KB Output is correct
44 Correct 1 ms 2140 KB Output is correct
45 Correct 1 ms 2140 KB Output is correct
46 Correct 1 ms 2140 KB Output is correct
47 Correct 1 ms 2140 KB Output is correct
48 Correct 1 ms 2140 KB Output is correct
49 Correct 1 ms 2356 KB Output is correct
50 Correct 3 ms 2596 KB Output is correct
51 Correct 3 ms 2652 KB Output is correct
52 Correct 3 ms 2652 KB Output is correct
53 Correct 3 ms 2396 KB Output is correct
54 Correct 2 ms 2396 KB Output is correct
55 Correct 4 ms 2652 KB Output is correct
56 Correct 4 ms 2652 KB Output is correct
57 Correct 3 ms 2724 KB Output is correct
58 Correct 1 ms 2140 KB Output is correct
59 Correct 1 ms 2140 KB Output is correct
60 Correct 1 ms 2292 KB Output is correct
61 Correct 2 ms 2396 KB Output is correct
62 Correct 2 ms 2428 KB Output is correct
63 Correct 1 ms 2396 KB Output is correct
64 Correct 1 ms 2140 KB Output is correct
65 Correct 3 ms 2396 KB Output is correct
66 Correct 1 ms 2136 KB Output is correct
67 Correct 1 ms 2140 KB Output is correct
68 Correct 1 ms 2140 KB Output is correct
69 Correct 2 ms 2140 KB Output is correct
70 Correct 2 ms 2396 KB Output is correct
71 Correct 370 ms 26504 KB Output is correct
72 Correct 257 ms 20376 KB Output is correct
73 Correct 332 ms 23632 KB Output is correct
74 Correct 176 ms 16464 KB Output is correct
75 Correct 173 ms 17584 KB Output is correct
76 Correct 580 ms 34772 KB Output is correct
77 Correct 472 ms 30804 KB Output is correct
78 Correct 433 ms 29268 KB Output is correct
79 Correct 453 ms 28496 KB Output is correct
80 Correct 1 ms 2136 KB Output is correct
81 Correct 2 ms 2140 KB Output is correct
82 Correct 3 ms 2652 KB Output is correct
83 Correct 38 ms 6488 KB Output is correct
84 Correct 53 ms 7516 KB Output is correct
85 Correct 11 ms 3868 KB Output is correct
86 Correct 1 ms 2136 KB Output is correct
87 Correct 59 ms 8436 KB Output is correct
88 Correct 1 ms 2136 KB Output is correct
89 Correct 1 ms 2140 KB Output is correct
90 Correct 1 ms 2140 KB Output is correct
91 Correct 22 ms 4700 KB Output is correct
92 Correct 76 ms 10496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2140 KB Output is correct
2 Correct 1 ms 2140 KB Output is correct
3 Correct 1 ms 2140 KB Output is correct
4 Correct 1 ms 2140 KB Output is correct
5 Correct 1 ms 2140 KB Output is correct
6 Correct 1 ms 2140 KB Output is correct
7 Correct 1 ms 2140 KB Output is correct
8 Correct 1 ms 2140 KB Output is correct
9 Correct 1 ms 2140 KB Output is correct
10 Correct 2 ms 2120 KB Output is correct
11 Correct 1 ms 2140 KB Output is correct
12 Correct 1 ms 2140 KB Output is correct
13 Correct 1 ms 2140 KB Output is correct
14 Correct 1 ms 2140 KB Output is correct
15 Correct 1 ms 2140 KB Output is correct
16 Correct 1 ms 2140 KB Output is correct
17 Correct 1 ms 2140 KB Output is correct
18 Correct 1 ms 2140 KB Output is correct
19 Correct 1 ms 2140 KB Output is correct
20 Correct 1 ms 2140 KB Output is correct
21 Correct 1 ms 2140 KB Output is correct
22 Correct 1 ms 2140 KB Output is correct
23 Correct 1 ms 2136 KB Output is correct
24 Correct 1 ms 2140 KB Output is correct
25 Correct 1 ms 2140 KB Output is correct
26 Correct 2 ms 2396 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2140 KB Output is correct
29 Correct 1 ms 2140 KB Output is correct
30 Correct 1 ms 2140 KB Output is correct
31 Correct 2 ms 2396 KB Output is correct
32 Correct 2 ms 2396 KB Output is correct
33 Correct 1 ms 2396 KB Output is correct
34 Correct 1 ms 2140 KB Output is correct
35 Correct 1 ms 2140 KB Output is correct
36 Correct 1 ms 2136 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2136 KB Output is correct
39 Correct 1 ms 2140 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 2 ms 2648 KB Output is correct
42 Correct 1 ms 2332 KB Output is correct
43 Correct 1 ms 2140 KB Output is correct
44 Correct 1 ms 2140 KB Output is correct
45 Correct 1 ms 2140 KB Output is correct
46 Correct 1 ms 2140 KB Output is correct
47 Correct 1 ms 2140 KB Output is correct
48 Correct 1 ms 2140 KB Output is correct
49 Correct 1 ms 2356 KB Output is correct
50 Correct 3 ms 2596 KB Output is correct
51 Correct 3 ms 2652 KB Output is correct
52 Correct 3 ms 2652 KB Output is correct
53 Correct 3 ms 2396 KB Output is correct
54 Correct 2 ms 2396 KB Output is correct
55 Correct 4 ms 2652 KB Output is correct
56 Correct 4 ms 2652 KB Output is correct
57 Correct 3 ms 2724 KB Output is correct
58 Correct 1 ms 2140 KB Output is correct
59 Correct 1 ms 2140 KB Output is correct
60 Correct 1 ms 2292 KB Output is correct
61 Correct 2 ms 2396 KB Output is correct
62 Correct 2 ms 2428 KB Output is correct
63 Correct 1 ms 2396 KB Output is correct
64 Correct 1 ms 2140 KB Output is correct
65 Correct 3 ms 2396 KB Output is correct
66 Correct 1 ms 2136 KB Output is correct
67 Correct 1 ms 2140 KB Output is correct
68 Correct 1 ms 2140 KB Output is correct
69 Correct 2 ms 2140 KB Output is correct
70 Correct 2 ms 2396 KB Output is correct
71 Correct 370 ms 26504 KB Output is correct
72 Correct 257 ms 20376 KB Output is correct
73 Correct 332 ms 23632 KB Output is correct
74 Correct 176 ms 16464 KB Output is correct
75 Correct 173 ms 17584 KB Output is correct
76 Correct 580 ms 34772 KB Output is correct
77 Correct 472 ms 30804 KB Output is correct
78 Correct 433 ms 29268 KB Output is correct
79 Correct 453 ms 28496 KB Output is correct
80 Correct 1 ms 2136 KB Output is correct
81 Correct 2 ms 2140 KB Output is correct
82 Correct 3 ms 2652 KB Output is correct
83 Correct 38 ms 6488 KB Output is correct
84 Correct 53 ms 7516 KB Output is correct
85 Correct 11 ms 3868 KB Output is correct
86 Correct 1 ms 2136 KB Output is correct
87 Correct 59 ms 8436 KB Output is correct
88 Correct 1 ms 2136 KB Output is correct
89 Correct 1 ms 2140 KB Output is correct
90 Correct 1 ms 2140 KB Output is correct
91 Correct 22 ms 4700 KB Output is correct
92 Correct 76 ms 10496 KB Output is correct
93 Correct 2652 ms 104532 KB Output is correct
94 Correct 1433 ms 70988 KB Output is correct
95 Correct 1641 ms 74364 KB Output is correct
96 Correct 1347 ms 66640 KB Output is correct
97 Correct 1283 ms 60756 KB Output is correct
98 Correct 2584 ms 115236 KB Output is correct
99 Correct 2870 ms 117072 KB Output is correct
100 Correct 2666 ms 112592 KB Output is correct
101 Correct 2704 ms 104244 KB Output is correct
102 Correct 2332 ms 94164 KB Output is correct
103 Correct 1744 ms 84648 KB Output is correct
104 Correct 1 ms 2140 KB Output is correct
105 Correct 1 ms 2140 KB Output is correct
106 Correct 5 ms 2908 KB Output is correct
107 Correct 134 ms 14580 KB Output is correct
108 Correct 330 ms 28752 KB Output is correct
109 Correct 25 ms 5976 KB Output is correct
110 Correct 1 ms 2140 KB Output is correct
111 Correct 160 ms 17868 KB Output is correct
112 Correct 1 ms 2140 KB Output is correct
113 Correct 1 ms 2140 KB Output is correct
114 Correct 4 ms 2908 KB Output is correct
115 Correct 2 ms 2140 KB Output is correct
116 Correct 11 ms 3888 KB Output is correct
117 Correct 460 ms 34456 KB Output is correct