首页 > 其他 > 详细

SPOJ #11 Factorial

时间:2014-02-04 22:49:41      阅读:393      评论:0      收藏:0      [点我收藏+]

Counting trailing 0s of n! It is not very hard to figure out how to count it - simply count how many 5s. Since even numbers are always more than 5s, we don‘t have to consider even numbers.

But counting 5, is tricky. Naive method is quite slow - I got 12+s for 1000000000. And after reading below article, I got 0.04s. The former counts individually, duplicated; but the latter counts smart:
http://en.wikipedia.org/wiki/Trailing_zeros#Factorial

SPOJ #11 Factorial

原文:http://www.cnblogs.com/tonix/p/3537830.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!