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;
}