Điểm:
100 (p)
Thời gian:
1.0s
Bộ nhớ:
1G
Input:
bàn phím
Output:
màn hình
Đếm số lượng chữ số \(0\) của \(n!\).
Input
- Dòng đầu tiên là số lượng test case \(T\ (1 \le n \le 100)\).
- \(T\) dòng tiếp theo mỗi dòng là một số nguyên dương \(n\ (1 \le n \le 10^6)\).
Output
- In ra số lượng chữ số \(0\) liên tiếp tính từ cuối của \(n!\).
Example
Test 1
Input
2
10
20
Output
2
4
Bình luận
help với nào, tui đề phòng số lớn trước khi nộp bài mà nó bị lỗi rồi:
//#pragma GCC optimize("Ofast","03","unroll-loops")
include <bits/stdc++.h>
using namespace std;
template<typename... T>
void see(T&... args) { ((cin >> args), ...);}
template<typename... T>
void put(T&&... args) { ((cout << args << " "), ...);}
template<typename... T>
void putl(T&&... args) { ((cout << args << " "), ...); cout<<'\n';}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << "=" << a << ", "; err(++it, args...);}
define error(args...)
define ll long long
define pb push_back
define F first
define S second
define ll long long
define ull unsigned long long
define ld long double
define pii pair<long long,long long>
define vl vector<long long>
define vii vector<pii>
define vc vector
define ERROR cerr<<'\n';
define all(x) x.begin(),x.end()
define setpr(x) cout<<setprecision(x)<<fixed
define sz size()
define seea(a,x,y) for(long long i=x;i<y;++i){cin>>a[i];}
define seev(v,n) for(long long i=0;i<n;++i){long long x; cin>>x; v.push_back(x);}
define sees(s,n) for(long long i=0;i<n;++i){long long x; cin>>x; s.insert(x);}
define rep(i,n,m) for(long long i=m;i<n;++i)
define rex(i,n,m) for(long long i=m;i<=n;++i)
define rev(i,n,m) for(long long i=n;i>=m;--i)
string tich(ll a,ll b) { //FAST IO
string d="";
ll x=0;
while(a!=0) {
ll k=(a%10)*b+x;
a/=10,x=k/10;
d=char(k%10+48)+d;
}
if(x>0) d=to_string(x)+d;
return d;
}
string tong(string a,string b) {
string d="";
ll x=0;
while(a.sz<b.sz) a='0'+a; while(a.sz>b.sz) b='0'+b;
for(ll i=a.sz-1;i>=0;--i) {
ll tong=a[i]+b[i]+x-96;
d=char(tong%10+48)+d;
x=tong/10;
}
if(x==1) d='1'+d;
return d;
}
string thuong(string a, int b) {
string d;
ll x=0;
rep(i,a.sz,0) {
x=x*10+int(a[i]-48);
d=d+char(x/b+48);
x%=b;
}
while(d.sz>1 && d[0]=='0') d.erase(0,1);
return d;
}
ll slove() {
ll n;
see(n);
string f="1";
ll dem=0;
rex(i,n,2) f = tich(stoi(f),i);
rev(i,f.size()-1,0) {
if(f[i]=='0') ++dem;
else break;
}
return dem;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
#ifdef LOCAL
freopen("input.INP", "r" , stdin);
freopen("output.OUT", "w", stdout);
#endif
//code here
ll t;
cin >> t;
while(t--) putl(slove());
#ifdef LOCAL
clock_t tStart = clock();
cerr<<fixed<<setprecision(10)<<"\nTime Taken: "<<(double)(clock()- tStart)/CLOCKS_PER_SEC<<'\n';
#endif
}
//using setup code by Sachin Srivastava (mrsac7)
//no copy AC code