-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path047-dmopc-16-contest-2-p4-zeros.cpp
More file actions
63 lines (61 loc) · 1.28 KB
/
Copy path047-dmopc-16-contest-2-p4-zeros.cpp
File metadata and controls
63 lines (61 loc) · 1.28 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
61
62
63
/*
* DMOPC '16 Contest 2 P4 - Zeros [dmopc16c2p4]
* Problem: https://dmoj.ca/problem/dmopc16c2p4
* Verdict: ACCEPTED (7.0 pts) Solved: 2022-02-15
* Language: C++20
* Runtime: 0.04999315 s Memory: 3168.0 KB
* Source: https://dmoj.ca/src/4343870
*/
/// ya rab AC
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void ACPLS()
{
#ifndef ONLINE_JUDGE
freopen("output.txt", "w", stdout);
freopen("input.txt", "r", stdin);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
#define tc \
int tttttt,subtask; \
cin >> tttttt /*>> subtask*/; \
while (tttttt--)
#define sumrange(l, r, arr) (l == 0 ? arr[r] : arr[r] - arr[l - 1])
#define all(v) v.begin(), v.end()
ll f(ll n, ll p){
ll ret=0;
while(n){
ret+=n/p;
n/=p;
}
return ret;
}
int main()
{
ACPLS();
ll a,b;
cin>>a>>b;
ll lo = 1, hi = 1e18, l = hi, r = lo;
while(lo<=hi){
ll mid = (lo+hi)/2;
if(min(f(mid,2),f(mid,5))>=a){
l=mid;
hi=mid-1;
}
else lo=mid+1;
}
lo=1,hi=1e18;
while(lo<=hi){
ll mid = (lo+hi)/2;
if(min(f(mid,2),f(mid,5))<=b){
r=mid;
lo=mid+1;
}
else hi=mid-1;
}
cout<<r-l+1;
}