阶乘问题
Time Limit:1000MS Memory Limit:65536K
Total Submit:16 Accepted:9
Description
从输入文件中读取一个数n,求出n!中末尾0的个数。
Input
输入有若干行。每一行上有一个整数m,指明接下来的数字的个数。然后是m行,每一行包含一个确定的正整数n,1£n£1000000000。
Output
对输入行中的每一个数据n,输出一行,其内容是n!中末尾0的个数。
Sample Input
3 3 100 1024
3 3 100 1024
Sample Output
0 24 253
0 24 253
Source
----------------code---------------------
#include <stdio.h> int main(){ int n,sum=0,a; scanf("%d",&n); while(n) { scanf("%d",&a); for(;a!=0;){ sum += a/5; a=a/5; } printf("%d/n",sum); sum=0; n--; } }