Submit | All submissions | Best solutions | Back to list |
FACTZERO - Zeros of factorial |
Wersja polska | English version |
Given integer n, print number of final zeros of n! (which is factorial of n).
Input
The first line of the standard input contains one integer t (t<2001) which is the number of test cases.
In each of the next t lines there is number n (0<=n<=10^9).
Output
For each test, print the number of final zeros of n!.
Example
Input:
2
10
1000000
Output:
2
249998
Special thanks to Rafał Spręga for the concept of this task.
Added by: | Piotr Kąkol |
Date: | 2009-12-26 |
Time limit: | 6.466s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NODEJS OBJC SCM qobi VB.NET |
hide comments
|
|||||
2018-08-21 16:38:50
ranking page is not working??? |
|||||
2014-12-04 00:40:15 Piotr KÄ…kol
NZEC is very general for Perl, Python and similar languages. It doesn't help much unfortunately. In your case: Can't take log of 0 at prog.pl line 1, <> chunk 1.
|
|||||
2014-12-03 21:22:20 Kurt Schwind
I'm getting NZEC for my perl solution. I know all hardware is different but I'm running 1000 9 digit numbers through in under 20ms. And I'm not printing out any real numbers. All int. Solution : 13049814 Last edit: 2014-12-04 00:39:21 |
|||||
2013-08-12 16:20:15 Robert Gerbicz
First solution in brainfuck! It took only 0.14 sec. and 1472 bytes of code. |
|||||
2010-04-17 15:39:57 Piotr KÄ…kol
Test changed and submissions rejudged. Now in free time I'll change some other tests like numerix asked in comment. But my top priority is to make as many tasks as possible in order to encourage more contestants and not make You all bored so maybe I'll add some tasks before complying numerix's request. ;-) |
|||||
2010-04-11 10:37:28 Piotr KÄ…kol
For 5*10^9 the answer should be 1249999999998 ;-) I will change tests with max 10^9. Last edit: 2010-04-11 10:40:55 |
|||||
2010-04-11 09:07:32 Zoltán Zámbori
5 sec timeout is not enough. Let it be 20 :-) At home the same factzero solution print 1_249_999_999_997 (input: 5_000_000_000_000) in less than 0.3 sec on my old laptop. Something must be wrong with the installed Perl. Last edit: 2010-04-11 09:21:53 |
|||||
2010-04-10 21:03:17 Piotr KÄ…kol
Send me something and I will send You Your code but changed to receive not TLE but WA. Last edit: 2012-04-26 17:35:29 |
|||||
2010-04-10 18:43:54 Zoltán Zámbori
I give up. I have no idea why i get "time limit exceeded". Can You check this: 3491420? It is very frustrating that i cant post any solution to bigmath problems because of "time limit..." :-( |
|||||
2010-04-10 17:30:12 Piotr KÄ…kol
n<=10^9 is enough? |