poj 1401 Factorial
2011-07-22 14:51
387 查看
#include <iostream> using namespace std; int factorial(int n) { int s=0; while(n>=5) { s+=n/5; n=n/5; } return s; } int main() { int t,n; cin>>t; while(t--) { cin>>n; cout<<factorial(n)<<endl; } } //逢五进一,比如60 //有 5 10 15 20 25 30 35 40 45 50 55 60 (60/5=12) //上面的数列除以5后,得 1 2 3 4 5 6 7 8 9 10 11 12 //其中有 5 10 能再被5整除 (12/5=2) // 25和50 各含有 5 的因子 2 个, (25 ,50 分别乘以 4 , 2 后边就都有2个0)
相关文章推荐
- POJ_1401_Factorial(阶乘末尾0)
- POJ 1401:Factorial 求一个数阶乘的末尾0的个数
- poj 1401 Factorial
- Poj 1401 Factorial(计算N!尾数0的个数——质因数分解)
- Poj 1401 Factorial
- poj 1401 Factorial
- POJ 1401:Factorial 求一个数阶乘的末尾0的个数
- POJ1401 - Factorial
- Poj 1401 Factorial(计算N!尾数0的个数——质因数分解)
- poj1401——Factorial
- 【POJ】1401 - Factorial(阶乘最后0的个数)
- POJ 1401 Factorial
- POJ1401-Factorial
- zoj 2022||poj 1401 Factorial(阶乘)
- poj 1401 Factorial
- POJ 1401 Factorial (对数学知识考…
- POJ 1401 Factorial
- POJ 1401 && ZOJ 2202 Factorial 阶乘N!的末尾零的个数
- POJ 1401 Factorial
- poj 1401 Factorial