N! SDUT 3138

题目描述

首先很感谢刘老师能给我这次机会给大家出题,希望大家做完题后能有所收获,如果有任何问题还请海涵,毕竟出套题不容易……TAT
题目整体不难,大体是给我带的大一新生出题的难度,所以请各位放心。
If you want to learn something from other people, remember, stay hunger.---shadow95
Now, your first problem comes~
This task is very simple, please calculate how many zeros are there at the end of calculation of n!.
For example, 15! = 1307674368000, so answer is 3.

输入

 At the first line, there is a number T indicating the number of test cases.
Then, following T lines, each line there is a number n (n<10^9).

输出

For each case, output the case number and answer in one line.

示例输入

3
5
100
1024

示例输出

Case #1: 1
Case #2: 24
Case #3: 253

找规律,醉了吧,一直除5.

<pre name="code" class="cpp">#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>

using namespace std;

int main()
{
    int n,t;
    cin>>t;
    for(int i=1; i<=t; i++)
    {
        cin>>n;
        int k=0;
        while(n!=0)
        {
            k+=n/5;
            n=n/5;
        }
        cout<<"Case #"<<i<<": "<<k<<endl;

    }
    return 0;
}

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值