답안 #493257

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493257 2021-12-10T14:08:27 Z blue Toys (CEOI18_toy) C++17
100 / 100
853 ms 93188 KB
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <cassert>
#include <unordered_set>
using namespace std;

#define sz(x) (int(x.size()))
using vi = vector<int>;
using ll = long long;

// map< int, vector<int> > res;

vi sf;

long long n;

unordered_set<int> res[40'000]; //i*i <= n
unordered_set<int> res2[40'000]; //i*i >= n, access n/i.

vi solved(1+40'000, 0);
vi solved2(1+40'000, 0);

vector<int> factors[40'000];
vector<int> factors2[40'000];

unordered_set<int>& get_res(long long u)
{
    if(u*u <= n) return res[u];
    else return res2[n/u];
}

vector<int>& get_factors(long long u)
{
    if(u*u <= n) return factors[u];
    else return factors2[n/u];
}

int& get_solved(long long u)
{
    if(u*u <= n) return solved[u];
    else return solved2[n/u];
}



void solve(long long i)
{
    get_res(i).insert(i-1);

    for(ll j: get_factors(i))
    {
        for(int k: get_res(j))
            get_res(i).insert(k + i/j - 1);

    }
}

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

    cin >> n;

    if(n == 1)
    {
        cout << "1\n 0\n";
        return 0;
    }



    for(int i = 2; i < n; i++)
    {
        // cerr << i << " " << n%i << ' ' << int(n%i == 0) << '\n';
        if(i*i > n) break;
        if(n % i == 0)
        {
            sf.push_back(i);
            sf.push_back(n/i);
        }
    }
    sf.push_back(n);

    sort(sf.begin(), sf.end());
    sf.erase(unique(sf.begin(), sf.end()), sf.end());

    // for(int q: sf) cerr << q << ' ';
    // cerr << '\n';

    for(int a: sf)
        for(int b: sf)
            if(a < b && b%a==0)
                get_factors(b).push_back(a);


    for(int a: sf) solve(a);
    unordered_set<int> ans = get_res(n);
    set<int> A;
  for(int a: ans) A.insert(a);

    cout << sz(A) << '\n';
    for(int r: A) cout << r << ' ';
    cout << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6860 KB Output is correct
2 Correct 4 ms 6860 KB Output is correct
3 Correct 4 ms 6860 KB Output is correct
4 Correct 4 ms 6860 KB Output is correct
5 Correct 4 ms 6860 KB Output is correct
6 Correct 4 ms 6860 KB Output is correct
7 Correct 4 ms 6860 KB Output is correct
8 Correct 6 ms 6832 KB Output is correct
9 Correct 5 ms 6836 KB Output is correct
10 Correct 4 ms 6860 KB Output is correct
11 Correct 5 ms 6860 KB Output is correct
12 Correct 3 ms 6860 KB Output is correct
13 Correct 4 ms 6860 KB Output is correct
14 Correct 4 ms 6860 KB Output is correct
15 Correct 4 ms 6860 KB Output is correct
16 Correct 4 ms 6860 KB Output is correct
17 Correct 4 ms 6880 KB Output is correct
18 Correct 4 ms 6860 KB Output is correct
19 Correct 5 ms 6860 KB Output is correct
20 Correct 4 ms 6860 KB Output is correct
21 Correct 4 ms 6860 KB Output is correct
22 Correct 4 ms 6860 KB Output is correct
23 Correct 4 ms 6860 KB Output is correct
24 Correct 4 ms 6860 KB Output is correct
25 Correct 5 ms 6860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6860 KB Output is correct
2 Correct 4 ms 6860 KB Output is correct
3 Correct 4 ms 6860 KB Output is correct
4 Correct 4 ms 6860 KB Output is correct
5 Correct 4 ms 6860 KB Output is correct
6 Correct 4 ms 6860 KB Output is correct
7 Correct 4 ms 6860 KB Output is correct
8 Correct 6 ms 6832 KB Output is correct
9 Correct 5 ms 6836 KB Output is correct
10 Correct 4 ms 6860 KB Output is correct
11 Correct 5 ms 6860 KB Output is correct
12 Correct 3 ms 6860 KB Output is correct
13 Correct 4 ms 6860 KB Output is correct
14 Correct 4 ms 6860 KB Output is correct
15 Correct 4 ms 6860 KB Output is correct
16 Correct 4 ms 6860 KB Output is correct
17 Correct 4 ms 6880 KB Output is correct
18 Correct 4 ms 6860 KB Output is correct
19 Correct 5 ms 6860 KB Output is correct
20 Correct 4 ms 6860 KB Output is correct
21 Correct 4 ms 6860 KB Output is correct
22 Correct 4 ms 6860 KB Output is correct
23 Correct 4 ms 6860 KB Output is correct
24 Correct 4 ms 6860 KB Output is correct
25 Correct 5 ms 6860 KB Output is correct
26 Correct 6 ms 6988 KB Output is correct
27 Correct 4 ms 6860 KB Output is correct
28 Correct 4 ms 6860 KB Output is correct
29 Correct 4 ms 6860 KB Output is correct
30 Correct 3 ms 6860 KB Output is correct
31 Correct 4 ms 6988 KB Output is correct
32 Correct 4 ms 6860 KB Output is correct
33 Correct 4 ms 6860 KB Output is correct
34 Correct 4 ms 6860 KB Output is correct
35 Correct 3 ms 6860 KB Output is correct
36 Correct 4 ms 6860 KB Output is correct
37 Correct 6 ms 6860 KB Output is correct
38 Correct 5 ms 6852 KB Output is correct
39 Correct 4 ms 6860 KB Output is correct
40 Correct 5 ms 6860 KB Output is correct
41 Correct 4 ms 6860 KB Output is correct
42 Correct 5 ms 6860 KB Output is correct
43 Correct 5 ms 6860 KB Output is correct
44 Correct 4 ms 6860 KB Output is correct
45 Correct 4 ms 6860 KB Output is correct
46 Correct 4 ms 6860 KB Output is correct
47 Correct 4 ms 6968 KB Output is correct
48 Correct 4 ms 6860 KB Output is correct
49 Correct 4 ms 6860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6860 KB Output is correct
2 Correct 4 ms 6860 KB Output is correct
3 Correct 4 ms 6860 KB Output is correct
4 Correct 4 ms 6860 KB Output is correct
5 Correct 4 ms 6860 KB Output is correct
6 Correct 4 ms 6860 KB Output is correct
7 Correct 4 ms 6860 KB Output is correct
8 Correct 6 ms 6832 KB Output is correct
9 Correct 5 ms 6836 KB Output is correct
10 Correct 4 ms 6860 KB Output is correct
11 Correct 5 ms 6860 KB Output is correct
12 Correct 3 ms 6860 KB Output is correct
13 Correct 4 ms 6860 KB Output is correct
14 Correct 4 ms 6860 KB Output is correct
15 Correct 4 ms 6860 KB Output is correct
16 Correct 4 ms 6860 KB Output is correct
17 Correct 4 ms 6880 KB Output is correct
18 Correct 4 ms 6860 KB Output is correct
19 Correct 5 ms 6860 KB Output is correct
20 Correct 4 ms 6860 KB Output is correct
21 Correct 4 ms 6860 KB Output is correct
22 Correct 4 ms 6860 KB Output is correct
23 Correct 4 ms 6860 KB Output is correct
24 Correct 4 ms 6860 KB Output is correct
25 Correct 5 ms 6860 KB Output is correct
26 Correct 6 ms 6988 KB Output is correct
27 Correct 4 ms 6860 KB Output is correct
28 Correct 4 ms 6860 KB Output is correct
29 Correct 4 ms 6860 KB Output is correct
30 Correct 3 ms 6860 KB Output is correct
31 Correct 4 ms 6988 KB Output is correct
32 Correct 4 ms 6860 KB Output is correct
33 Correct 4 ms 6860 KB Output is correct
34 Correct 4 ms 6860 KB Output is correct
35 Correct 3 ms 6860 KB Output is correct
36 Correct 4 ms 6860 KB Output is correct
37 Correct 6 ms 6860 KB Output is correct
38 Correct 5 ms 6852 KB Output is correct
39 Correct 4 ms 6860 KB Output is correct
40 Correct 5 ms 6860 KB Output is correct
41 Correct 4 ms 6860 KB Output is correct
42 Correct 5 ms 6860 KB Output is correct
43 Correct 5 ms 6860 KB Output is correct
44 Correct 4 ms 6860 KB Output is correct
45 Correct 4 ms 6860 KB Output is correct
46 Correct 4 ms 6860 KB Output is correct
47 Correct 4 ms 6968 KB Output is correct
48 Correct 4 ms 6860 KB Output is correct
49 Correct 4 ms 6860 KB Output is correct
50 Correct 5 ms 7244 KB Output is correct
51 Correct 4 ms 7116 KB Output is correct
52 Correct 4 ms 7116 KB Output is correct
53 Correct 5 ms 7116 KB Output is correct
54 Correct 5 ms 6988 KB Output is correct
55 Correct 8 ms 7232 KB Output is correct
56 Correct 6 ms 7264 KB Output is correct
57 Correct 6 ms 7244 KB Output is correct
58 Correct 4 ms 6860 KB Output is correct
59 Correct 4 ms 6860 KB Output is correct
60 Correct 4 ms 6860 KB Output is correct
61 Correct 5 ms 7116 KB Output is correct
62 Correct 4 ms 6988 KB Output is correct
63 Correct 4 ms 6860 KB Output is correct
64 Correct 4 ms 6860 KB Output is correct
65 Correct 5 ms 7116 KB Output is correct
66 Correct 3 ms 6860 KB Output is correct
67 Correct 4 ms 6860 KB Output is correct
68 Correct 4 ms 6860 KB Output is correct
69 Correct 4 ms 6860 KB Output is correct
70 Correct 6 ms 6988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6860 KB Output is correct
2 Correct 4 ms 6860 KB Output is correct
3 Correct 4 ms 6860 KB Output is correct
4 Correct 4 ms 6860 KB Output is correct
5 Correct 4 ms 6860 KB Output is correct
6 Correct 4 ms 6860 KB Output is correct
7 Correct 4 ms 6860 KB Output is correct
8 Correct 6 ms 6832 KB Output is correct
9 Correct 5 ms 6836 KB Output is correct
10 Correct 4 ms 6860 KB Output is correct
11 Correct 5 ms 6860 KB Output is correct
12 Correct 3 ms 6860 KB Output is correct
13 Correct 4 ms 6860 KB Output is correct
14 Correct 4 ms 6860 KB Output is correct
15 Correct 4 ms 6860 KB Output is correct
16 Correct 4 ms 6860 KB Output is correct
17 Correct 4 ms 6880 KB Output is correct
18 Correct 4 ms 6860 KB Output is correct
19 Correct 5 ms 6860 KB Output is correct
20 Correct 4 ms 6860 KB Output is correct
21 Correct 4 ms 6860 KB Output is correct
22 Correct 4 ms 6860 KB Output is correct
23 Correct 4 ms 6860 KB Output is correct
24 Correct 4 ms 6860 KB Output is correct
25 Correct 5 ms 6860 KB Output is correct
26 Correct 6 ms 6988 KB Output is correct
27 Correct 4 ms 6860 KB Output is correct
28 Correct 4 ms 6860 KB Output is correct
29 Correct 4 ms 6860 KB Output is correct
30 Correct 3 ms 6860 KB Output is correct
31 Correct 4 ms 6988 KB Output is correct
32 Correct 4 ms 6860 KB Output is correct
33 Correct 4 ms 6860 KB Output is correct
34 Correct 4 ms 6860 KB Output is correct
35 Correct 3 ms 6860 KB Output is correct
36 Correct 4 ms 6860 KB Output is correct
37 Correct 6 ms 6860 KB Output is correct
38 Correct 5 ms 6852 KB Output is correct
39 Correct 4 ms 6860 KB Output is correct
40 Correct 5 ms 6860 KB Output is correct
41 Correct 4 ms 6860 KB Output is correct
42 Correct 5 ms 6860 KB Output is correct
43 Correct 5 ms 6860 KB Output is correct
44 Correct 4 ms 6860 KB Output is correct
45 Correct 4 ms 6860 KB Output is correct
46 Correct 4 ms 6860 KB Output is correct
47 Correct 4 ms 6968 KB Output is correct
48 Correct 4 ms 6860 KB Output is correct
49 Correct 4 ms 6860 KB Output is correct
50 Correct 5 ms 7244 KB Output is correct
51 Correct 4 ms 7116 KB Output is correct
52 Correct 4 ms 7116 KB Output is correct
53 Correct 5 ms 7116 KB Output is correct
54 Correct 5 ms 6988 KB Output is correct
55 Correct 8 ms 7232 KB Output is correct
56 Correct 6 ms 7264 KB Output is correct
57 Correct 6 ms 7244 KB Output is correct
58 Correct 4 ms 6860 KB Output is correct
59 Correct 4 ms 6860 KB Output is correct
60 Correct 4 ms 6860 KB Output is correct
61 Correct 5 ms 7116 KB Output is correct
62 Correct 4 ms 6988 KB Output is correct
63 Correct 4 ms 6860 KB Output is correct
64 Correct 4 ms 6860 KB Output is correct
65 Correct 5 ms 7116 KB Output is correct
66 Correct 3 ms 6860 KB Output is correct
67 Correct 4 ms 6860 KB Output is correct
68 Correct 4 ms 6860 KB Output is correct
69 Correct 4 ms 6860 KB Output is correct
70 Correct 6 ms 6988 KB Output is correct
71 Correct 137 ms 25844 KB Output is correct
72 Correct 108 ms 21204 KB Output is correct
73 Correct 128 ms 23508 KB Output is correct
74 Correct 69 ms 18136 KB Output is correct
75 Correct 70 ms 18884 KB Output is correct
76 Correct 191 ms 31916 KB Output is correct
77 Correct 190 ms 29092 KB Output is correct
78 Correct 176 ms 27900 KB Output is correct
79 Correct 144 ms 27216 KB Output is correct
80 Correct 4 ms 6860 KB Output is correct
81 Correct 4 ms 6860 KB Output is correct
82 Correct 5 ms 7244 KB Output is correct
83 Correct 22 ms 10540 KB Output is correct
84 Correct 32 ms 11204 KB Output is correct
85 Correct 11 ms 8268 KB Output is correct
86 Correct 4 ms 6860 KB Output is correct
87 Correct 30 ms 12000 KB Output is correct
88 Correct 4 ms 6860 KB Output is correct
89 Correct 5 ms 6860 KB Output is correct
90 Correct 4 ms 6860 KB Output is correct
91 Correct 12 ms 9036 KB Output is correct
92 Correct 34 ms 13748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6860 KB Output is correct
2 Correct 4 ms 6860 KB Output is correct
3 Correct 4 ms 6860 KB Output is correct
4 Correct 4 ms 6860 KB Output is correct
5 Correct 4 ms 6860 KB Output is correct
6 Correct 4 ms 6860 KB Output is correct
7 Correct 4 ms 6860 KB Output is correct
8 Correct 6 ms 6832 KB Output is correct
9 Correct 5 ms 6836 KB Output is correct
10 Correct 4 ms 6860 KB Output is correct
11 Correct 5 ms 6860 KB Output is correct
12 Correct 3 ms 6860 KB Output is correct
13 Correct 4 ms 6860 KB Output is correct
14 Correct 4 ms 6860 KB Output is correct
15 Correct 4 ms 6860 KB Output is correct
16 Correct 4 ms 6860 KB Output is correct
17 Correct 4 ms 6880 KB Output is correct
18 Correct 4 ms 6860 KB Output is correct
19 Correct 5 ms 6860 KB Output is correct
20 Correct 4 ms 6860 KB Output is correct
21 Correct 4 ms 6860 KB Output is correct
22 Correct 4 ms 6860 KB Output is correct
23 Correct 4 ms 6860 KB Output is correct
24 Correct 4 ms 6860 KB Output is correct
25 Correct 5 ms 6860 KB Output is correct
26 Correct 6 ms 6988 KB Output is correct
27 Correct 4 ms 6860 KB Output is correct
28 Correct 4 ms 6860 KB Output is correct
29 Correct 4 ms 6860 KB Output is correct
30 Correct 3 ms 6860 KB Output is correct
31 Correct 4 ms 6988 KB Output is correct
32 Correct 4 ms 6860 KB Output is correct
33 Correct 4 ms 6860 KB Output is correct
34 Correct 4 ms 6860 KB Output is correct
35 Correct 3 ms 6860 KB Output is correct
36 Correct 4 ms 6860 KB Output is correct
37 Correct 6 ms 6860 KB Output is correct
38 Correct 5 ms 6852 KB Output is correct
39 Correct 4 ms 6860 KB Output is correct
40 Correct 5 ms 6860 KB Output is correct
41 Correct 4 ms 6860 KB Output is correct
42 Correct 5 ms 6860 KB Output is correct
43 Correct 5 ms 6860 KB Output is correct
44 Correct 4 ms 6860 KB Output is correct
45 Correct 4 ms 6860 KB Output is correct
46 Correct 4 ms 6860 KB Output is correct
47 Correct 4 ms 6968 KB Output is correct
48 Correct 4 ms 6860 KB Output is correct
49 Correct 4 ms 6860 KB Output is correct
50 Correct 5 ms 7244 KB Output is correct
51 Correct 4 ms 7116 KB Output is correct
52 Correct 4 ms 7116 KB Output is correct
53 Correct 5 ms 7116 KB Output is correct
54 Correct 5 ms 6988 KB Output is correct
55 Correct 8 ms 7232 KB Output is correct
56 Correct 6 ms 7264 KB Output is correct
57 Correct 6 ms 7244 KB Output is correct
58 Correct 4 ms 6860 KB Output is correct
59 Correct 4 ms 6860 KB Output is correct
60 Correct 4 ms 6860 KB Output is correct
61 Correct 5 ms 7116 KB Output is correct
62 Correct 4 ms 6988 KB Output is correct
63 Correct 4 ms 6860 KB Output is correct
64 Correct 4 ms 6860 KB Output is correct
65 Correct 5 ms 7116 KB Output is correct
66 Correct 3 ms 6860 KB Output is correct
67 Correct 4 ms 6860 KB Output is correct
68 Correct 4 ms 6860 KB Output is correct
69 Correct 4 ms 6860 KB Output is correct
70 Correct 6 ms 6988 KB Output is correct
71 Correct 137 ms 25844 KB Output is correct
72 Correct 108 ms 21204 KB Output is correct
73 Correct 128 ms 23508 KB Output is correct
74 Correct 69 ms 18136 KB Output is correct
75 Correct 70 ms 18884 KB Output is correct
76 Correct 191 ms 31916 KB Output is correct
77 Correct 190 ms 29092 KB Output is correct
78 Correct 176 ms 27900 KB Output is correct
79 Correct 144 ms 27216 KB Output is correct
80 Correct 4 ms 6860 KB Output is correct
81 Correct 4 ms 6860 KB Output is correct
82 Correct 5 ms 7244 KB Output is correct
83 Correct 22 ms 10540 KB Output is correct
84 Correct 32 ms 11204 KB Output is correct
85 Correct 11 ms 8268 KB Output is correct
86 Correct 4 ms 6860 KB Output is correct
87 Correct 30 ms 12000 KB Output is correct
88 Correct 4 ms 6860 KB Output is correct
89 Correct 5 ms 6860 KB Output is correct
90 Correct 4 ms 6860 KB Output is correct
91 Correct 12 ms 9036 KB Output is correct
92 Correct 34 ms 13748 KB Output is correct
93 Correct 743 ms 83724 KB Output is correct
94 Correct 441 ms 59612 KB Output is correct
95 Correct 494 ms 61884 KB Output is correct
96 Correct 424 ms 56168 KB Output is correct
97 Correct 373 ms 52140 KB Output is correct
98 Correct 791 ms 92016 KB Output is correct
99 Correct 853 ms 93188 KB Output is correct
100 Correct 772 ms 90288 KB Output is correct
101 Correct 747 ms 83968 KB Output is correct
102 Correct 639 ms 76244 KB Output is correct
103 Correct 584 ms 69440 KB Output is correct
104 Correct 5 ms 6988 KB Output is correct
105 Correct 4 ms 6860 KB Output is correct
106 Correct 7 ms 7628 KB Output is correct
107 Correct 57 ms 16804 KB Output is correct
108 Correct 134 ms 27784 KB Output is correct
109 Correct 20 ms 10188 KB Output is correct
110 Correct 4 ms 6896 KB Output is correct
111 Correct 80 ms 19340 KB Output is correct
112 Correct 4 ms 6844 KB Output is correct
113 Correct 4 ms 6860 KB Output is correct
114 Correct 7 ms 7628 KB Output is correct
115 Correct 4 ms 6860 KB Output is correct
116 Correct 10 ms 8524 KB Output is correct
117 Correct 159 ms 32440 KB Output is correct