Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- ll findTrailingZeros(ll n)
- {
- int count = 0;
- for (int i = 5; n / i >= 1; i *= 5)
- count += n / i;
- return count;
- }
- int main()
- {
- ll t,n,l,h,c,m;
- cin>>t;
- c=1;
- while(t--)
- {
- cin>>n;
- l=0,h=ll(1e18+9);
- while (l <= h) {
- m = (l + h) / 2;
- if (findTrailingZeros(m)< n)
- l = m + 1;
- else
- h = m - 1;
- }
- if(findTrailingZeros(m)!=n)printf("Case %d: impossible\n",c++);
- else printf("Case %d: %lld\n",c++,m) ;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement