标签:http java ar line new .net on acm
任何一个数分解质因数后,表达为2的x1次方 * 3的x2次方 * 5 的x3次方 等等
0的来源于2*5,x1》x2 ,所以阶乘中0的个数为5的个数,下面就很简单了。
http://acm.nyist.net/JudgeOnline/problem.php?pid=84
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scn=new Scanner(System.in);
int len=scn.nextInt();
while(len-->0)
{
System.out.println(fun1(scn.nextInt()));
}
}
private static int fun1(int next) {
// TODO Auto-generated method stub
int count=0;
int n=next;
while(n!=0)
{
count+=(n/5);
n=n/5;
}
return count;
}
}
标签:http java ar line new .net on acm
原文地址:http://www.cnblogs.com/hansongjiang/p/3913722.html