POJ 1401 Factorial
2012-05-06 18:25
323 查看
求 n! 末尾零的个数,在编程之美上看过,其实也不难:求因子2和5的个数取最小值,因为5出现的频率远低于2。
# include <stdio.h> int solve(int n); int main() { int T, n; scanf("%d", &T); while (T--) { scanf("%d", &n); printf("%d\n", solve(n)); } return 0; } int solve(int n) { int t; t = 0; while (n>0) {n /= 5; t += n;} return t; }
相关文章推荐
- poj1401--Factorial
- poj 1401 Factorial
- Poj 1401 Factorial(计算N!尾数0的个数——质因数分解)
- poj 1401 Factorial
- Poj 1401 Factorial
- poj 1401 Factorial
- POJ_1401_Factorial(阶乘末尾0)
- POJ 1401:Factorial 求一个数阶乘的末尾0的个数
- POJ1401 - Factorial
- Poj 1401 Factorial(计算N!尾数0的个数——质因数分解)
- poj1401——Factorial
- POJ 1401:Factorial 求一个数阶乘的末尾0的个数
- 【POJ】1401 - Factorial(阶乘最后0的个数)
- POJ 1401 Factorial
- POJ1401-Factorial
- zoj 2022||poj 1401 Factorial(阶乘)
- POJ 1401 Factorial (对数学知识考…
- poj 1401 Factorial
- POJ 1401 && ZOJ 2202 Factorial 阶乘N!的末尾零的个数
- POJ 1401 Factorial