sdut2500 0\'s 阶乘相关

来源:互联网 发布:淘宝累计销量没有了 编辑:程序博客网 时间:2024/06/04 01:28

求阶乘末尾零个数的方法,刚学会的

具体参见http://blog.sina.com.cn/s/blog_4fd55a4f01007ugc.html

http://blog.sina.com.cn/s/blog_5f36f8370100eb0h.html

#include<iostream>#include<cstring>#include<cstdio>#define ll long long using namespace std;ll a;ll f(ll t){if(t<5) return 0;return t/5+f(t/5);}int main(){int t;scanf("%d",&t);while(t--){scanf("%ld",&a);printf("%ld\n",f(a));}return 0;} /**************************************Problem id: SDUT OJ 2500 Result: Accepted Take Memory: 456K Take Time: 0MS Submit Time: 2013-06-02 00:43:23  **************************************/


原创粉丝点击