Factorial
Time Limit: 1500MS   Memory Limit: 65536K
Total Submissions: 15137   Accepted: 9349

Description

The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term gave the name to the cellular phone) and every phone connects to the BTS with the strongest signal (in a little simplified
view). Of course, BTSes need some attention and technicians need to check their function periodically. 



ACM technicians faced a very interesting problem recently. Given a set of BTSes to visit, they needed to find the shortest path to visit all of the given points and return back to the central company building. Programmers have spent several months studying
this problem but with no results. They were unable to find the solution fast enough. After a long time, one of the programmers found this problem in a conference article. Unfortunately, he found that the problem is so called "Travelling Salesman Problem" and
it is very hard to solve. If we have N BTSes to be visited, we can visit them in any order, giving us N! possibilities to examine. The function expressing that number is called factorial and can be computed as a product 1.2.3.4....N. The number is very high
even for a relatively small N. 



The programmers understood they had no chance to solve the problem. But because they have already received the research grant from the government, they needed to continue with their studies and produce at least some results. So they started to study behaviour
of the factorial function. 



For example, they defined the function Z. For any positive integer N, Z(N) is the number of zeros at the end of the decimal form of number N!. They noticed that this function never decreases. If we have two numbers N1 < N2, then Z(N1) <= Z(N2). It is because
we can never "lose" any trailing zero by multiplying by any positive number. We can only get new and new zeros. The function Z is very interesting, so we need a computer program that can determine its value efficiently. 


Input

There is a single positive integer T on the first line of input. It stands for the number of numbers to follow. Then there is T lines, each containing exactly one positive integer number N, 1 <= N <= 1000000000.

Output

For every number N, output a single line containing the single non-negative integer Z(N).

Sample Input

6
3
60
100
1024
23456
8735373

Sample Output

0
14
24
253
5861
2183837

题意是求一个数阶乘的末尾0的个数,相乘能在末尾多产生0的,只能是乘以10,即因子中含有2和5的,因为偶数的数量远远大于5的数量,所以这个题目就是要求一个数有多少个5,有多少个25,有多少个125。。。。

代码:

#include <iostream>
using namespace std; int main()
{
int Test,n,result;
cin >> Test; while (Test--)
{
cin >> n;
result = 0; while (n > 0)
{
result += n / 5;
n = n / 5;
}
cout << result << endl;
}
return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

最新文章

  1. MySQL性能优化——索引
  2. Unity3D代码旋转
  3. IntelliJ IDEA 导入新项目以后的简单配置
  4. linux文件远程传输客户端shell脚本与分布式客户机时间同步脚本
  5. Mysql----------的一些常用命令
  6. 用Javascript取float型小数点
  7. JavaWeb项目开发案例精粹-第3章在线考试系统-007View层
  8. C#扫盲之:带你掌握C#的扩展方法、以及探讨扩展方法的本质、注意事项
  9. js正则验证两位小数 验证数字最简单正则表达式大全
  10. 手机SIM卡无法识别解决方案
  11. 动力IT教育背后的“神秘力量”
  12. 博客志第一天——判断一个整数N是否是完全平方数?
  13. C#设计模式--简单工厂模式
  14. 使用Python的requests库进行接口测试——session对象的妙用
  15. mysql中有关查询的技巧方法
  16. 【python基础】常用的内置函数
  17. [LeetCode&amp;Python] Problem 371. Sum of Two Integers
  18. VS2010编译Boost 1.56
  19. sublime 技巧与快捷键篇
  20. 2018-2019-2 20165209 《网络对抗技术》Exp7: 网络欺诈防范

热门文章

  1. firewalld学习--service
  2. 求第K大数(分治)
  3. 第四张5G牌照发给广电,能打破三大运营商的垄断吗?
  4. nodejs 编译时对项目进行配置
  5. 002. 使用IDEA创建MyBatis的JAVAWEB项目 ,每一步都有详细过程,完美绕过各种坑能正常运行
  6. 认识json,详解JsonConfig
  7. Ubuntu18.04 LTS 搭建Cassandra集群
  8. Docker-harbor-V1.3.0 ”私有仓库“搭建 Easy
  9. ES6学习笔记-扩展运算符(...)
  10. UVA - 1152 4 Values whose Sum is 0(中途相遇法)