4.26 腾讯笔试
有没有人写了n!末尾q个0,最小的n,二分一直0%...求大佬指点
#include<bits/stdc++.h> using namespace std; #define ll long long ll ss(ll n) { ll w=5; ll ans=0; while(n/w) { ans+=n/w; w*=5; } return ans; } int main() { int t; cin>>t; ll n; while(t--) { cin>>n; ll l=1,r=10000000000000000; while(l<r) { ll mid=(l+r)/2; if(ss(mid)<n) l=mid+1; else r=mid; } cout<<l<<endl; } }