commit f6cc5ecf4d3336e8be4e7f455e027a9b2ad1fd5e parent 2938136f517c280ab61100f9f528977f4a1656cf Author: superpozycja <anna@superpozycja.net> Date: Thu, 24 Oct 2024 00:40:26 +0200 solve trailing zeros Diffstat:
A | intro/trailing_zeros.cpp | | | 40 | ++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 40 insertions(+), 0 deletions(-)
diff --git a/intro/trailing_zeros.cpp b/intro/trailing_zeros.cpp @@ -0,0 +1,40 @@ +#include <bits/stdc++.h> + +using namespace std; + +using ui = unsigned int; +using l = long; +using ul = unsigned long; +using ll = long long; +using ull = unsigned long long; + +using vi = vector<int>; +using vui = vector<ui>; +using vl = vector<l>; +using vul = vector<ul>; +using vll = vector<ll>; +using vull = vector<ull>; + +void solve() +{ + int n; + cin >> n; + int tmp = n, f = 0, t = 0; + while (tmp > 0) { + tmp /= 5; + f += tmp; + } + + tmp = n; + while (tmp > 0) { + tmp /= 2; + t += tmp; + } + + cout << (f < t ? f : t) << "\n"; +} + +int main() +{ + solve(); +}