Submission #1009068

# Submission time Handle Problem Language Result Execution time Memory
1009068 2024-06-27T08:32:30 Z christinelynn Toys (CEOI18_toy) C++17
100 / 100
380 ms 4432 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef unsigned long long ull;
typedef unsigned long long int ulli;
typedef long long ll;
typedef long long int lli;
typedef long double ld;
typedef string st;
#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
#define ppf pop_front
#define ppb pop_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0);
#define pii pair<int, int>
#define psi pair<string, int>
#define F first
#define S second
#define p(a, b) pair<a, b>
#define vin vector<int>
#define v(a) vector<a>
#define pll p(ll, ll)
//------------------------------------------------------------------------------------------------------------------
#define trace(x) cout<<"> "<<#x<<" : "<<x<<endl
#define trace2(x,y) cout<<"> "<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<endl
#define trace3(x,y,z) cout<<"> "<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<" | "<<#z<<" : "<<z<<endl
#define trace4(w,x,y,z) cout<<"> "<<#w<<" : "<<w<<" | "<<#x<<" : "<<x<<" | "<<#y<<" : "<<y<<" | "<<#z<<" : "<<z<<endl
// CONSTANT
#define mod     1000000007 // 1e9+7
#define mods    998244353  // Prime
#define eps     0.000000001 // 1e-9
#define inf     2147483647 // INT_MAX
#define INF     9223372036854775807 // LLONG_MAX
//-------------------------------------------------------------------------------------------------------------------
template<typename T>
void print(pair<T, T> var) { // print pair
        cout << var.first << ' ' << var.second << endl;
}

template<typename T>
void print(vector<T> var) { // print vector
        for(auto i : var) {
                cout << i << ' ';
        } cout << endl;
}

template<typename T>
void print(vector<pair<T, T>> var) { //print vector pair
        for(auto &i : var) {
                cout << i.first << ' ' << i.second << endl;
        }
}
//---------------------------------------------------------------------------------------------------------------------------

set<ll> ans;
void solve(ll fac, ll temp, ll sum){
    if(temp <= 0) return;
    // trace3(fac, temp, sum);
    ans.insert(sum + (fac-1) + (temp-1));
    if(fac == 1) return;
    for(int i = fac; i*i <= temp; i++){
        if(temp%i == 0) solve(i, temp/i, sum+(fac-1));
    }
    return;
}

int main(){
fastIO
//int t; cin >> t;
//  while(t--){

//  }
ll n; cin >> n;
v(ll) fct;
for(int i = 1; i*i <= n; i++){
    if(n%i == 0){
        fct.pb(i);
        if(n/i != i) fct.pb(n/i);
    }
}

sort(all(fct));
for(auto i : fct){
    solve(i, n/i, 0);
}
// trace(1);
cout << ans.size() << '\n';
for(auto i : ans) cout << i << " ";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 456 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 456 KB Output is correct
22 Correct 1 ms 456 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 456 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 456 KB Output is correct
22 Correct 1 ms 456 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 460 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 352 KB Output is correct
34 Correct 0 ms 464 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 456 KB Output is correct
39 Correct 1 ms 464 KB Output is correct
40 Correct 0 ms 600 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 460 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 604 KB Output is correct
47 Correct 1 ms 352 KB Output is correct
48 Correct 1 ms 352 KB Output is correct
49 Correct 0 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 456 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 456 KB Output is correct
22 Correct 1 ms 456 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 460 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 352 KB Output is correct
34 Correct 0 ms 464 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 456 KB Output is correct
39 Correct 1 ms 464 KB Output is correct
40 Correct 0 ms 600 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 460 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 604 KB Output is correct
47 Correct 1 ms 352 KB Output is correct
48 Correct 1 ms 352 KB Output is correct
49 Correct 0 ms 352 KB Output is correct
50 Correct 1 ms 460 KB Output is correct
51 Correct 1 ms 356 KB Output is correct
52 Correct 1 ms 468 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 1 ms 352 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 0 ms 456 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 1 ms 456 KB Output is correct
64 Correct 0 ms 460 KB Output is correct
65 Correct 1 ms 352 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 0 ms 460 KB Output is correct
68 Correct 0 ms 352 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 456 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 456 KB Output is correct
22 Correct 1 ms 456 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 460 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 352 KB Output is correct
34 Correct 0 ms 464 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 456 KB Output is correct
39 Correct 1 ms 464 KB Output is correct
40 Correct 0 ms 600 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 460 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 604 KB Output is correct
47 Correct 1 ms 352 KB Output is correct
48 Correct 1 ms 352 KB Output is correct
49 Correct 0 ms 352 KB Output is correct
50 Correct 1 ms 460 KB Output is correct
51 Correct 1 ms 356 KB Output is correct
52 Correct 1 ms 468 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 1 ms 352 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 0 ms 456 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 1 ms 456 KB Output is correct
64 Correct 0 ms 460 KB Output is correct
65 Correct 1 ms 352 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 0 ms 460 KB Output is correct
68 Correct 0 ms 352 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
71 Correct 35 ms 1404 KB Output is correct
72 Correct 24 ms 1364 KB Output is correct
73 Correct 34 ms 1364 KB Output is correct
74 Correct 14 ms 944 KB Output is correct
75 Correct 18 ms 1160 KB Output is correct
76 Correct 62 ms 1744 KB Output is correct
77 Correct 72 ms 1440 KB Output is correct
78 Correct 49 ms 1652 KB Output is correct
79 Correct 47 ms 1372 KB Output is correct
80 Correct 1 ms 344 KB Output is correct
81 Correct 0 ms 348 KB Output is correct
82 Correct 1 ms 492 KB Output is correct
83 Correct 7 ms 604 KB Output is correct
84 Correct 8 ms 604 KB Output is correct
85 Correct 2 ms 604 KB Output is correct
86 Correct 0 ms 348 KB Output is correct
87 Correct 10 ms 860 KB Output is correct
88 Correct 1 ms 348 KB Output is correct
89 Correct 0 ms 348 KB Output is correct
90 Correct 1 ms 348 KB Output is correct
91 Correct 3 ms 604 KB Output is correct
92 Correct 11 ms 968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 460 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 456 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 456 KB Output is correct
22 Correct 1 ms 456 KB Output is correct
23 Correct 1 ms 604 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 460 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 352 KB Output is correct
34 Correct 0 ms 464 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 456 KB Output is correct
39 Correct 1 ms 464 KB Output is correct
40 Correct 0 ms 600 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 460 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 0 ms 604 KB Output is correct
47 Correct 1 ms 352 KB Output is correct
48 Correct 1 ms 352 KB Output is correct
49 Correct 0 ms 352 KB Output is correct
50 Correct 1 ms 460 KB Output is correct
51 Correct 1 ms 356 KB Output is correct
52 Correct 1 ms 468 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 1 ms 352 KB Output is correct
56 Correct 1 ms 348 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 0 ms 456 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 1 ms 456 KB Output is correct
64 Correct 0 ms 460 KB Output is correct
65 Correct 1 ms 352 KB Output is correct
66 Correct 0 ms 348 KB Output is correct
67 Correct 0 ms 460 KB Output is correct
68 Correct 0 ms 352 KB Output is correct
69 Correct 0 ms 348 KB Output is correct
70 Correct 1 ms 348 KB Output is correct
71 Correct 35 ms 1404 KB Output is correct
72 Correct 24 ms 1364 KB Output is correct
73 Correct 34 ms 1364 KB Output is correct
74 Correct 14 ms 944 KB Output is correct
75 Correct 18 ms 1160 KB Output is correct
76 Correct 62 ms 1744 KB Output is correct
77 Correct 72 ms 1440 KB Output is correct
78 Correct 49 ms 1652 KB Output is correct
79 Correct 47 ms 1372 KB Output is correct
80 Correct 1 ms 344 KB Output is correct
81 Correct 0 ms 348 KB Output is correct
82 Correct 1 ms 492 KB Output is correct
83 Correct 7 ms 604 KB Output is correct
84 Correct 8 ms 604 KB Output is correct
85 Correct 2 ms 604 KB Output is correct
86 Correct 0 ms 348 KB Output is correct
87 Correct 10 ms 860 KB Output is correct
88 Correct 1 ms 348 KB Output is correct
89 Correct 0 ms 348 KB Output is correct
90 Correct 1 ms 348 KB Output is correct
91 Correct 3 ms 604 KB Output is correct
92 Correct 11 ms 968 KB Output is correct
93 Correct 282 ms 4016 KB Output is correct
94 Correct 108 ms 3248 KB Output is correct
95 Correct 138 ms 3308 KB Output is correct
96 Correct 124 ms 2892 KB Output is correct
97 Correct 115 ms 2644 KB Output is correct
98 Correct 323 ms 4432 KB Output is correct
99 Correct 380 ms 4360 KB Output is correct
100 Correct 314 ms 4272 KB Output is correct
101 Correct 354 ms 4072 KB Output is correct
102 Correct 311 ms 3924 KB Output is correct
103 Correct 174 ms 3556 KB Output is correct
104 Correct 1 ms 348 KB Output is correct
105 Correct 0 ms 348 KB Output is correct
106 Correct 2 ms 348 KB Output is correct
107 Correct 31 ms 1224 KB Output is correct
108 Correct 68 ms 1876 KB Output is correct
109 Correct 8 ms 604 KB Output is correct
110 Correct 1 ms 604 KB Output is correct
111 Correct 38 ms 1524 KB Output is correct
112 Correct 1 ms 452 KB Output is correct
113 Correct 0 ms 348 KB Output is correct
114 Correct 3 ms 348 KB Output is correct
115 Correct 1 ms 348 KB Output is correct
116 Correct 9 ms 632 KB Output is correct
117 Correct 52 ms 2332 KB Output is correct