ECNU_OJ_1008
2016-04-02 23:11
253 查看
Zero
Time Limit:1000MS Memory Limit:30000KBTotal Submit:1470 Accepted:685
Description
A long time ago people found the value zero to be very useful. Just think about the romans and many more nations that didn’t know the zero. Their number representations couldn’t display the zero and that’s why they are dead now.So you’ve got to understand the overwhelming importance of this beautiful gift of science (or nature ?) and praise the zero. That’s what you’ll do here.
Find out how many trailing zeros are at the end of n! (n factorial). That’s all you have to do, but be careful to write an efficient program, n can be really large. For example,
42! = 1405006117752879898543142606244511569936384000000000
so the answer for n=42 would be 9, since there are nine zeros at the end.
Input
The first line contains an integer m, the number of test cases. After that follow m lines. Every line represents one testcase, which only contains the integer number n. The value of n will be at least 1 and won’t be bigger than 2.000.000.000.Output
For each testcase, print a line containing the number of trailing zeros. Do not print whitespace before or after the number.Sample Input
41
23
42
2000000000
Sample Output
04
9
499999997
Source
Freshman Programming Contest#include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { int n; scanf("%d", &n); for(int i = 0; i < n; i++) { int temp; int count = 0; scanf("%d", &temp); while(temp / 5 != 0) { count += temp / 5; temp /= 5; } printf("%d\n", count); } system("pause"); return 1; }
相关文章推荐
- 脏读 幻读 不可重复读简析
- Mongodb
- C++中的OOP
- LeetCode题解--8. String to Integer (atoi)
- [Commons]——队列包装
- Android学习之界面篇(一)Android Animation简单介绍
- CSDN-markdown学习ing
- Python multiprocessing threading
- java线程FAQ
- mysql 与文件系统缓存
- JavaScript 原型模式的理解
- 错误信息收集
- 写入文件和读取文件信息—Java Card开发第三篇
- python爬取某个贴吧帖子留下的邮箱,并自动发送相应链接
- Android 多线程文件断点下载器实现(造轮子系列)(二)
- CentOS7上安装稻壳CMS
- 20145330第五周《Java学习笔记》
- 30 段 JavaScript 代码
- python 安装第三方插件
- Java中,一个类实现某个接口,必须重写接口中的所有方法吗