답안 #459307

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
459307 2021-08-08T11:45:46 Z Killer2501 Toys (CEOI18_toy) C++14
100 / 100
885 ms 9104 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back

const int N = 1e5+5;
const long long mod = 1e9+7;
const long double pi = acos(-1);
const int base = 300;
ll k, t;
ll a[N], ans, m, n, b[N], tong, d[N], c[N], lab[N], cnt, h[N], P[N][20];
vector<pll> val[N];
vector<ll> adj[N], res;
ll pw(ll k, ll n)
{
    ll total = 1;
    for(; n; n >>= 1)
    {
        if(n & 1)total = total * k % mod;
        k = k * k % mod;
    }
    return total;
}
template<typename T>
void read(T&x)
{
    bool Neg=false;
    char c;
    for(c= getchar();c<'0'||c>'9';c=getchar())
        if(c=='-') Neg =!Neg;
    x = c-'0';
    for (c=getchar();c>='0'&&c<='9';c=getchar())
        x=x*10+c-'0';
    if(Neg&&x>0) x=-x;
}
ll findp(ll u)
{
    return lab[u] < 0 ? u : lab[u] = findp(lab[u]);
}
bool hop(ll u, ll v)
{
    u = findp(u);
    v = findp(v);
    if(u == v)return false;
    if(lab[u] > lab[v])swap(u, v);
    lab[u] += lab[v];
    lab[v] = u;
    return true;
}
string s;
void dfs(ll u, ll p)
{
   d[u] = ++t;
   for(ll i : adj[u])
   {
       ll v = a[i] + b[i] - u;
       if(v == p)continue;
       c[v] = i;
       P[v][0] = u;
       h[v] = h[u] + 1;
       for(int i = 1; i <= 18; i ++)P[v][i] = P[P[v][i-1]][i-1];
       dfs(v, u);
   }
}
set<ll> st;
void cal(ll n, ll lst, ll sum)
{
    st.insert(sum+n-1);
    for(int i = lst; i <= n / i; i ++)
    {
        if(n % i == 0)
        {
            cal(n/i, i, sum+i-1);
        }
    }
}
void sol()
{
    cin >> n;
    cal(n, 2, 0);
    cout << st.size() << '\n';
    for(ll x : st)cout << x <<" ";
}
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    #define task "testss"
    if(fopen(task".inp", "r"))
    {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    int ntest = 1;
    //cin >> ntest;
    while(ntest -- > 0)
    sol();
}
/*
10 4
5 4 3 2 -1 0 0 0 0 0



*/

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:95:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   95 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
toy.cpp:96:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   96 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 4 ms 5020 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 4 ms 5028 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 5 ms 4940 KB Output is correct
9 Correct 4 ms 4940 KB Output is correct
10 Correct 3 ms 4940 KB Output is correct
11 Correct 3 ms 4940 KB Output is correct
12 Correct 4 ms 4940 KB Output is correct
13 Correct 3 ms 5020 KB Output is correct
14 Correct 3 ms 4940 KB Output is correct
15 Correct 3 ms 4940 KB Output is correct
16 Correct 3 ms 4940 KB Output is correct
17 Correct 4 ms 5024 KB Output is correct
18 Correct 3 ms 4940 KB Output is correct
19 Correct 3 ms 5024 KB Output is correct
20 Correct 5 ms 4940 KB Output is correct
21 Correct 3 ms 4940 KB Output is correct
22 Correct 3 ms 5020 KB Output is correct
23 Correct 3 ms 4940 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 3 ms 4940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 4 ms 5020 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 4 ms 5028 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 5 ms 4940 KB Output is correct
9 Correct 4 ms 4940 KB Output is correct
10 Correct 3 ms 4940 KB Output is correct
11 Correct 3 ms 4940 KB Output is correct
12 Correct 4 ms 4940 KB Output is correct
13 Correct 3 ms 5020 KB Output is correct
14 Correct 3 ms 4940 KB Output is correct
15 Correct 3 ms 4940 KB Output is correct
16 Correct 3 ms 4940 KB Output is correct
17 Correct 4 ms 5024 KB Output is correct
18 Correct 3 ms 4940 KB Output is correct
19 Correct 3 ms 5024 KB Output is correct
20 Correct 5 ms 4940 KB Output is correct
21 Correct 3 ms 4940 KB Output is correct
22 Correct 3 ms 5020 KB Output is correct
23 Correct 3 ms 4940 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 3 ms 4940 KB Output is correct
26 Correct 3 ms 5024 KB Output is correct
27 Correct 5 ms 4940 KB Output is correct
28 Correct 3 ms 4940 KB Output is correct
29 Correct 3 ms 4940 KB Output is correct
30 Correct 3 ms 5020 KB Output is correct
31 Correct 4 ms 4940 KB Output is correct
32 Correct 4 ms 4940 KB Output is correct
33 Correct 3 ms 4940 KB Output is correct
34 Correct 3 ms 5020 KB Output is correct
35 Correct 3 ms 4940 KB Output is correct
36 Correct 3 ms 4940 KB Output is correct
37 Correct 3 ms 5024 KB Output is correct
38 Correct 3 ms 4940 KB Output is correct
39 Correct 3 ms 4940 KB Output is correct
40 Correct 3 ms 5020 KB Output is correct
41 Correct 3 ms 4940 KB Output is correct
42 Correct 3 ms 4940 KB Output is correct
43 Correct 3 ms 4940 KB Output is correct
44 Correct 3 ms 4940 KB Output is correct
45 Correct 3 ms 4940 KB Output is correct
46 Correct 3 ms 4940 KB Output is correct
47 Correct 3 ms 4940 KB Output is correct
48 Correct 3 ms 5024 KB Output is correct
49 Correct 3 ms 4940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 4 ms 5020 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 4 ms 5028 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 5 ms 4940 KB Output is correct
9 Correct 4 ms 4940 KB Output is correct
10 Correct 3 ms 4940 KB Output is correct
11 Correct 3 ms 4940 KB Output is correct
12 Correct 4 ms 4940 KB Output is correct
13 Correct 3 ms 5020 KB Output is correct
14 Correct 3 ms 4940 KB Output is correct
15 Correct 3 ms 4940 KB Output is correct
16 Correct 3 ms 4940 KB Output is correct
17 Correct 4 ms 5024 KB Output is correct
18 Correct 3 ms 4940 KB Output is correct
19 Correct 3 ms 5024 KB Output is correct
20 Correct 5 ms 4940 KB Output is correct
21 Correct 3 ms 4940 KB Output is correct
22 Correct 3 ms 5020 KB Output is correct
23 Correct 3 ms 4940 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 3 ms 4940 KB Output is correct
26 Correct 3 ms 5024 KB Output is correct
27 Correct 5 ms 4940 KB Output is correct
28 Correct 3 ms 4940 KB Output is correct
29 Correct 3 ms 4940 KB Output is correct
30 Correct 3 ms 5020 KB Output is correct
31 Correct 4 ms 4940 KB Output is correct
32 Correct 4 ms 4940 KB Output is correct
33 Correct 3 ms 4940 KB Output is correct
34 Correct 3 ms 5020 KB Output is correct
35 Correct 3 ms 4940 KB Output is correct
36 Correct 3 ms 4940 KB Output is correct
37 Correct 3 ms 5024 KB Output is correct
38 Correct 3 ms 4940 KB Output is correct
39 Correct 3 ms 4940 KB Output is correct
40 Correct 3 ms 5020 KB Output is correct
41 Correct 3 ms 4940 KB Output is correct
42 Correct 3 ms 4940 KB Output is correct
43 Correct 3 ms 4940 KB Output is correct
44 Correct 3 ms 4940 KB Output is correct
45 Correct 3 ms 4940 KB Output is correct
46 Correct 3 ms 4940 KB Output is correct
47 Correct 3 ms 4940 KB Output is correct
48 Correct 3 ms 5024 KB Output is correct
49 Correct 3 ms 4940 KB Output is correct
50 Correct 4 ms 5068 KB Output is correct
51 Correct 4 ms 4940 KB Output is correct
52 Correct 4 ms 4940 KB Output is correct
53 Correct 4 ms 4944 KB Output is correct
54 Correct 3 ms 4940 KB Output is correct
55 Correct 3 ms 5068 KB Output is correct
56 Correct 3 ms 5068 KB Output is correct
57 Correct 4 ms 5068 KB Output is correct
58 Correct 3 ms 4940 KB Output is correct
59 Correct 3 ms 4940 KB Output is correct
60 Correct 5 ms 4940 KB Output is correct
61 Correct 4 ms 5020 KB Output is correct
62 Correct 3 ms 4940 KB Output is correct
63 Correct 3 ms 4940 KB Output is correct
64 Correct 3 ms 5028 KB Output is correct
65 Correct 3 ms 5068 KB Output is correct
66 Correct 3 ms 4940 KB Output is correct
67 Correct 3 ms 4940 KB Output is correct
68 Correct 3 ms 4940 KB Output is correct
69 Correct 3 ms 4940 KB Output is correct
70 Correct 3 ms 4940 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 4 ms 5020 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 4 ms 5028 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 5 ms 4940 KB Output is correct
9 Correct 4 ms 4940 KB Output is correct
10 Correct 3 ms 4940 KB Output is correct
11 Correct 3 ms 4940 KB Output is correct
12 Correct 4 ms 4940 KB Output is correct
13 Correct 3 ms 5020 KB Output is correct
14 Correct 3 ms 4940 KB Output is correct
15 Correct 3 ms 4940 KB Output is correct
16 Correct 3 ms 4940 KB Output is correct
17 Correct 4 ms 5024 KB Output is correct
18 Correct 3 ms 4940 KB Output is correct
19 Correct 3 ms 5024 KB Output is correct
20 Correct 5 ms 4940 KB Output is correct
21 Correct 3 ms 4940 KB Output is correct
22 Correct 3 ms 5020 KB Output is correct
23 Correct 3 ms 4940 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 3 ms 4940 KB Output is correct
26 Correct 3 ms 5024 KB Output is correct
27 Correct 5 ms 4940 KB Output is correct
28 Correct 3 ms 4940 KB Output is correct
29 Correct 3 ms 4940 KB Output is correct
30 Correct 3 ms 5020 KB Output is correct
31 Correct 4 ms 4940 KB Output is correct
32 Correct 4 ms 4940 KB Output is correct
33 Correct 3 ms 4940 KB Output is correct
34 Correct 3 ms 5020 KB Output is correct
35 Correct 3 ms 4940 KB Output is correct
36 Correct 3 ms 4940 KB Output is correct
37 Correct 3 ms 5024 KB Output is correct
38 Correct 3 ms 4940 KB Output is correct
39 Correct 3 ms 4940 KB Output is correct
40 Correct 3 ms 5020 KB Output is correct
41 Correct 3 ms 4940 KB Output is correct
42 Correct 3 ms 4940 KB Output is correct
43 Correct 3 ms 4940 KB Output is correct
44 Correct 3 ms 4940 KB Output is correct
45 Correct 3 ms 4940 KB Output is correct
46 Correct 3 ms 4940 KB Output is correct
47 Correct 3 ms 4940 KB Output is correct
48 Correct 3 ms 5024 KB Output is correct
49 Correct 3 ms 4940 KB Output is correct
50 Correct 4 ms 5068 KB Output is correct
51 Correct 4 ms 4940 KB Output is correct
52 Correct 4 ms 4940 KB Output is correct
53 Correct 4 ms 4944 KB Output is correct
54 Correct 3 ms 4940 KB Output is correct
55 Correct 3 ms 5068 KB Output is correct
56 Correct 3 ms 5068 KB Output is correct
57 Correct 4 ms 5068 KB Output is correct
58 Correct 3 ms 4940 KB Output is correct
59 Correct 3 ms 4940 KB Output is correct
60 Correct 5 ms 4940 KB Output is correct
61 Correct 4 ms 5020 KB Output is correct
62 Correct 3 ms 4940 KB Output is correct
63 Correct 3 ms 4940 KB Output is correct
64 Correct 3 ms 5028 KB Output is correct
65 Correct 3 ms 5068 KB Output is correct
66 Correct 3 ms 4940 KB Output is correct
67 Correct 3 ms 4940 KB Output is correct
68 Correct 3 ms 4940 KB Output is correct
69 Correct 3 ms 4940 KB Output is correct
70 Correct 3 ms 4940 KB Output is correct
71 Correct 84 ms 6160 KB Output is correct
72 Correct 52 ms 5856 KB Output is correct
73 Correct 72 ms 5924 KB Output is correct
74 Correct 41 ms 5740 KB Output is correct
75 Correct 45 ms 5668 KB Output is correct
76 Correct 134 ms 6364 KB Output is correct
77 Correct 143 ms 6172 KB Output is correct
78 Correct 111 ms 6156 KB Output is correct
79 Correct 122 ms 6152 KB Output is correct
80 Correct 3 ms 4940 KB Output is correct
81 Correct 3 ms 4940 KB Output is correct
82 Correct 8 ms 5068 KB Output is correct
83 Correct 27 ms 5272 KB Output is correct
84 Correct 20 ms 5308 KB Output is correct
85 Correct 10 ms 5212 KB Output is correct
86 Correct 4 ms 4952 KB Output is correct
87 Correct 30 ms 5508 KB Output is correct
88 Correct 5 ms 4940 KB Output is correct
89 Correct 4 ms 4940 KB Output is correct
90 Correct 5 ms 4940 KB Output is correct
91 Correct 12 ms 5196 KB Output is correct
92 Correct 25 ms 5564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4992 KB Output is correct
2 Correct 3 ms 4940 KB Output is correct
3 Correct 3 ms 4940 KB Output is correct
4 Correct 4 ms 5020 KB Output is correct
5 Correct 3 ms 4940 KB Output is correct
6 Correct 4 ms 5028 KB Output is correct
7 Correct 4 ms 4940 KB Output is correct
8 Correct 5 ms 4940 KB Output is correct
9 Correct 4 ms 4940 KB Output is correct
10 Correct 3 ms 4940 KB Output is correct
11 Correct 3 ms 4940 KB Output is correct
12 Correct 4 ms 4940 KB Output is correct
13 Correct 3 ms 5020 KB Output is correct
14 Correct 3 ms 4940 KB Output is correct
15 Correct 3 ms 4940 KB Output is correct
16 Correct 3 ms 4940 KB Output is correct
17 Correct 4 ms 5024 KB Output is correct
18 Correct 3 ms 4940 KB Output is correct
19 Correct 3 ms 5024 KB Output is correct
20 Correct 5 ms 4940 KB Output is correct
21 Correct 3 ms 4940 KB Output is correct
22 Correct 3 ms 5020 KB Output is correct
23 Correct 3 ms 4940 KB Output is correct
24 Correct 4 ms 4940 KB Output is correct
25 Correct 3 ms 4940 KB Output is correct
26 Correct 3 ms 5024 KB Output is correct
27 Correct 5 ms 4940 KB Output is correct
28 Correct 3 ms 4940 KB Output is correct
29 Correct 3 ms 4940 KB Output is correct
30 Correct 3 ms 5020 KB Output is correct
31 Correct 4 ms 4940 KB Output is correct
32 Correct 4 ms 4940 KB Output is correct
33 Correct 3 ms 4940 KB Output is correct
34 Correct 3 ms 5020 KB Output is correct
35 Correct 3 ms 4940 KB Output is correct
36 Correct 3 ms 4940 KB Output is correct
37 Correct 3 ms 5024 KB Output is correct
38 Correct 3 ms 4940 KB Output is correct
39 Correct 3 ms 4940 KB Output is correct
40 Correct 3 ms 5020 KB Output is correct
41 Correct 3 ms 4940 KB Output is correct
42 Correct 3 ms 4940 KB Output is correct
43 Correct 3 ms 4940 KB Output is correct
44 Correct 3 ms 4940 KB Output is correct
45 Correct 3 ms 4940 KB Output is correct
46 Correct 3 ms 4940 KB Output is correct
47 Correct 3 ms 4940 KB Output is correct
48 Correct 3 ms 5024 KB Output is correct
49 Correct 3 ms 4940 KB Output is correct
50 Correct 4 ms 5068 KB Output is correct
51 Correct 4 ms 4940 KB Output is correct
52 Correct 4 ms 4940 KB Output is correct
53 Correct 4 ms 4944 KB Output is correct
54 Correct 3 ms 4940 KB Output is correct
55 Correct 3 ms 5068 KB Output is correct
56 Correct 3 ms 5068 KB Output is correct
57 Correct 4 ms 5068 KB Output is correct
58 Correct 3 ms 4940 KB Output is correct
59 Correct 3 ms 4940 KB Output is correct
60 Correct 5 ms 4940 KB Output is correct
61 Correct 4 ms 5020 KB Output is correct
62 Correct 3 ms 4940 KB Output is correct
63 Correct 3 ms 4940 KB Output is correct
64 Correct 3 ms 5028 KB Output is correct
65 Correct 3 ms 5068 KB Output is correct
66 Correct 3 ms 4940 KB Output is correct
67 Correct 3 ms 4940 KB Output is correct
68 Correct 3 ms 4940 KB Output is correct
69 Correct 3 ms 4940 KB Output is correct
70 Correct 3 ms 4940 KB Output is correct
71 Correct 84 ms 6160 KB Output is correct
72 Correct 52 ms 5856 KB Output is correct
73 Correct 72 ms 5924 KB Output is correct
74 Correct 41 ms 5740 KB Output is correct
75 Correct 45 ms 5668 KB Output is correct
76 Correct 134 ms 6364 KB Output is correct
77 Correct 143 ms 6172 KB Output is correct
78 Correct 111 ms 6156 KB Output is correct
79 Correct 122 ms 6152 KB Output is correct
80 Correct 3 ms 4940 KB Output is correct
81 Correct 3 ms 4940 KB Output is correct
82 Correct 8 ms 5068 KB Output is correct
83 Correct 27 ms 5272 KB Output is correct
84 Correct 20 ms 5308 KB Output is correct
85 Correct 10 ms 5212 KB Output is correct
86 Correct 4 ms 4952 KB Output is correct
87 Correct 30 ms 5508 KB Output is correct
88 Correct 5 ms 4940 KB Output is correct
89 Correct 4 ms 4940 KB Output is correct
90 Correct 5 ms 4940 KB Output is correct
91 Correct 12 ms 5196 KB Output is correct
92 Correct 25 ms 5564 KB Output is correct
93 Correct 618 ms 8736 KB Output is correct
94 Correct 336 ms 8004 KB Output is correct
95 Correct 364 ms 7904 KB Output is correct
96 Correct 318 ms 7632 KB Output is correct
97 Correct 294 ms 7216 KB Output is correct
98 Correct 780 ms 9076 KB Output is correct
99 Correct 879 ms 9104 KB Output is correct
100 Correct 779 ms 8884 KB Output is correct
101 Correct 885 ms 8740 KB Output is correct
102 Correct 783 ms 8480 KB Output is correct
103 Correct 488 ms 8304 KB Output is correct
104 Correct 4 ms 4940 KB Output is correct
105 Correct 4 ms 4940 KB Output is correct
106 Correct 11 ms 5020 KB Output is correct
107 Correct 102 ms 5800 KB Output is correct
108 Correct 207 ms 6572 KB Output is correct
109 Correct 33 ms 5336 KB Output is correct
110 Correct 5 ms 4940 KB Output is correct
111 Correct 125 ms 6028 KB Output is correct
112 Correct 4 ms 4940 KB Output is correct
113 Correct 4 ms 4940 KB Output is correct
114 Correct 14 ms 5068 KB Output is correct
115 Correct 3 ms 4940 KB Output is correct
116 Correct 33 ms 5188 KB Output is correct
117 Correct 138 ms 6944 KB Output is correct