-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path033-zeros.cpp
More file actions
45 lines (43 loc) · 1016 Bytes
/
Copy path033-zeros.cpp
File metadata and controls
45 lines (43 loc) · 1016 Bytes
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
/*
* Zeros [103148A]
* Problem: Gym/ICPC contest 103148 - problem A
* Verdict: ACCEPTED Solved: 2023-12-09
* Language: C++20 (GCC 11-64)
* Runtime: 15 ms Memory: 0 KB
* Tags: n/a
* Author: BidoTeima
* Source: https://codeforces.com/gym/103148/submission/236488833
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll f(ll a, ll b, int base){
ll ret = 0;
for(ll c = base, i = 1; c <= 1e18; c *= base, i++){
ll lo = 1, hi = 2e18 / c, mid;
bool yes=0;
while(lo <= hi){
mid=(lo+hi)>>1;
if(a <= mid * c && mid * c <= b){
yes=1;
break;
}
else if(mid * c < a){
lo = mid + 1;
}
else hi = mid - 1;
}
if(yes)ret=i;
}
return ret;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
ll a,b;
cin>>a>>b;
cout<<min(f(a, b, 2), f(a, b, 5));
return 0;
}