设为首页 加入收藏

TOP

HDU 1124 Factorial (??)
2015-07-20 17:31:56 来源: 作者: 【 】 浏览:3
Tags:HDU 1124 Factorial

?

?

?目好?好?,好可怕,看完?都萎了,以後肯定活不?,我可不能死在??小事上,小灰灰我?志死在少女的超短裙下~~~哈哈,所以我就猥?的叫 旁?的小?妹?我翻?了,我是不是很禽?,嘻嘻~~~

?

?目大意呢,就是?一??,要你求出它的?乘的得到的?果後面有??0;

?

解析:

一看就是????啦,跟?因子有?,最小素因子而且相乘能得到10的(就是後面有0的)就是2*5啦,因?一??的?乘2的因子明?比5的因子要多得多,所以末尾0的??不能取?于2因子的??啦,只能取5因子的??就ok了,然後,有一?小小的公式:

求N!中素因子p的?? 直接:

[ n/p ] + [ n/p^2 ] + [ n/p^3 ] + .....(?止?件: n >= p^x)

?

代?:

?

#include 
  
   
#include 
   
     #include 
    
      #include 
     
       using namespace std; int res, n, m, temp, cas; int main() { scanf(%d, &cas); while(cas--) { scanf(%d, &n); temp = n, m = 5, res = 0; while(m <= temp) { res += temp/m; m *= 5; } printf(%d , res); } return 0; } 
     
    
   
  


?

?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇多线程互斥--mutex 下一篇Clone Graph [leetcode] dfs和bfs

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·About - Redis (2025-12-26 08:20:56)
·Redis: A Comprehens (2025-12-26 08:20:53)
·Redis - The Real-ti (2025-12-26 08:20:50)
·Bash 脚本教程——Li (2025-12-26 07:53:35)
·实战篇!Linux shell (2025-12-26 07:53:32)