-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path154.cpp
More file actions
60 lines (49 loc) · 1.06 KB
/
154.cpp
File metadata and controls
60 lines (49 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// in the name of God
# include <bits/stdc++.h>
using namespace std;
# define pb push_back
# define slark cerr << "slark" << endl;
# define dagon cout << endl;
# define XX first
# define YY second
# define err(x) cout << #x << " is: " << x << endl;
# define Wait() int _; cin >> _;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pii;
const double PI = 3.1415931;
const double eps = 1e-9;
int check(int x) {
int ret = 0;
int p5 = 5;
while (x >= p5) {
ret += x / p5;
p5 *= 5;
}
return ret;
}
int binary_search(int q) {
int low = 1;
int high = 1000000000;
while (low != high) {
int mid = (low + high) / 2;
if (q <= check(mid)) {
high = mid;
} else {
low = mid + 1;
}
}
return low;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int q;
cin >> q;
int candidate = binary_search(q);
if (check(candidate) == q)
cout << candidate << endl;
else
cout << "No solution" << endl;
return 0;
}