首页 > 代码库 > NEFU 118

NEFU 118

其实一道公式题:

n!中素数i的幂为:

[n/i]+[n/i^2]+[n/i^3]+[n/i^4]+......

#include <iostream>#include <cstdio>#include <algorithm>using namespace std;long long n;int main(){	long long two,five; int t;	scanf("%d",&t);	while(t--){		scanf("%lld",&n);		two=five=0;		for(long long i=2;i<=n;i*=2)		two+=(n/i);		for(long long i=5;i<=n;i*=5)		five+=(n/i);		printf("%lld\n",two>five?five:two);	}	return 0;}

  

NEFU 118