trailing_zeros.cpp (543B)
1 #include <bits/stdc++.h> 2 3 using namespace std; 4 5 using ui = unsigned int; 6 using l = long; 7 using ul = unsigned long; 8 using ll = long long; 9 using ull = unsigned long long; 10 11 using vi = vector<int>; 12 using vui = vector<ui>; 13 using vl = vector<l>; 14 using vul = vector<ul>; 15 using vll = vector<ll>; 16 using vull = vector<ull>; 17 18 void solve() 19 { 20 int n; 21 cin >> n; 22 int tmp = n, f = 0, t = 0; 23 while (tmp > 0) { 24 tmp /= 5; 25 f += tmp; 26 } 27 28 tmp = n; 29 while (tmp > 0) { 30 tmp /= 2; 31 t += tmp; 32 } 33 34 cout << (f < t ? f : t) << "\n"; 35 } 36 37 int main() 38 { 39 solve(); 40 }