n的阶乘的结果有几个零
#include <iostream> using namespace std; int main() { int n, ans = 0; cin >> n; while (n) { ans += n/5,n/=5; } cout << ans << endl; return 0; }
其实就是求5的个数
n的结果有几位
#include <bits/stdc++.h> using namespace std; int main() { int n; double ans = 0; cin >> n; for(int i=1;i<=n;i++) { ans+=log10(i); } cout << (int)ans+1 << endl; return 0; }