# 0 of nyoj-84-factorial

Source: Internet
Author: User
0 of factorial Time limit:3000MS | memory limit:65535KB Difficulty:3

Description

Calculate n! In decimal format.

Input

Enter an integer N in the first line to indicate the number of groups of test data (1 <= n <= 100)

Each group of test data occupies one row, with only one integer m (0 <= m <= 10000000)

Output

Number of the last 0 in the decimal number of the factorial output M

For example, 5! = 120 then the number of the last 0 is 1

Sample Input

` 63601001024234568735373 `

Sample output

```  0142425358612183837      resolution: considering that 0 can only be obtained from" 2*5 ", and a" 5 "can easily match" 2, (because the number of "2" is much greater than the number of "5"), you only need to calculate the number of "5". Here, we take 720 as an example, to calculate the number of "5. That is, sum = 0; 720/5 = 144; sum + = 144; 144/5 = 28; sum + = 28; 28/5 = 5; sum + = 5; 5/5 = 1; sum + = 1; the calculation here is equivalent to 1 5 ^ 4, 5-1 5 ^ 3, 28-5-1 5 ^ 720-28-5-1 5 in 2,144.     the  Code  is as follows:      # include

int main () {int n, m, sum; scanf ("% d", & N); While (n --) {sum = 0; scanf ("% d", & M); While (m) {M/= 5; sum + = m;} printf ("% d \ n ", sum) ;}
```
Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.