文章

5

粉丝

100

获赞

2

访问

46.1k

头像
数学问题,没考算法
P1626 上海交通大学2018年机试题
发布于2021年2月28日 23:20
阅读数 7.5k

#include<iostream>
#include<algorithm>
using namespace std;

int main(){
	int n;
	while(cin>>n){
		int cnt2 = 0, cnt5 = 0, temp = 2;
		while(temp <= n){
			cnt2 += n/temp;
			temp *= 2;
		}
		temp = 5;
		while(temp <= n){
			cnt5 += n/temp;
			temp *= 5;
		}
		cout<<min(cnt2, cnt5)<<endl;
	}
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发