sdnu1250递归

1250.F.陆历川让你A个题
Description

This a veryyyyyyyyyyyyyy hard problem.One day, Lulichuan was played in city X with his friend, they like to paly a game called hide and seek,they was playing hide-and-seek, and suddenly a gust of wind blew up. The wind rolled up all the dust, so they went into a house to take refuge and stayed in the house so boring that they turned around. At the time, a small partner discovered a strange house. His surroundings were gleaming. At this time they cautiously walked into this shimmering room. They found an ancient cheat in the room. With ancient books, if anyone can solve for the number of zeros at the end of a number’ factorial .who will get a mysterious treasure, they soon find out the answer, but they are afraid of making mistakes, so they hope you can count them again. In order to help them test the answer.

Input

The first line T(0 < T< 1000)Follow T line every line a N(0 < N < 1000000)

Output

Answer

Sample Input

2
5
6

Sample Output

1
1

找n中有多少个5相乘 递归水题

#include<bits/stdc++.h>
using namespace std;
int digui(int n)
{
    if(n==0||n==1)
        return 0;
    else
        return n/5+digui(n/5);
}
int main()
{
    int n,t,m;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        int ans;
        ans=digui(n);
        cout<<ans<<'\n';
    }
    return 0;
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值