2018 第九屆藍橋杯省賽總結 + 解題報告(C語言B組)3.乘積尾零

#include <bits/stdc++.h>
using namespace std;
int main()
{
	#ifdef ONLINE_JUDGE
	#else
	freopen("in.txt", "r", stdin);
	#endif
	
	int c2 = 0, c5 = 0;
	int N;
	int i;
	
	for(i = 0; i < 100; i++){
		cin >> N;
		
		while(N % 2 == 0){
			N /= 2;
			c2++;
		}
		while(N % 5 == 0){
			N /= 5;
			c5++;
		}
	}
	
	cout << min(c2, c5);
	return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章