标签:
#include <iostream> #include <math.h> #include <vector> using namespace std; class Solution { public: int trailingZeroes(int n) { int retCnt=0,tmp5=5; while(tmp5<=n){ // cout<<tmp5<<" "<<n<<endl; retCnt+=n/tmp5; tmp5*=5; if(tmp5%5!=0) break; } return retCnt; } }; int main() { Solution sol; // for(int i =1;i<=50;i++){ // cout<<"i="<<i<<":"<<sol.trailingZeroes(i)<<endl; // } cout<<sol.trailingZeroes(1808548329)<<endl; cout<<INT_MAX<<endl; return 0; }
[LeetCode] Factorial Trailing Zeroes 阶乘末尾0
标签:
原文地址:http://www.cnblogs.com/Azhu/p/4212082.html