Scroll indicator done
728x90

https://www.acmicpc.net/problem/1676


#include <iostream>
using namespace std;

int n;
int cnt;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	cin >> n;
	while (n >= 5) {
		cnt += n / 5;
		n /= 5;
	}
	cout << cnt;
}

다른 사람 알고리즘 찾아보기 ..

요즘 풀고 나서 찾았던 알고리즘 중 제일 충격 

세상 제일 짧다 ..

#include <iostream>
using namespace std;

int n;

int main() {
	cin >> n;
	cout << n/5 + n/25 + n/125;
}

근데 시간은 똑같네

 

728x90

'BAEKJOON > C++' 카테고리의 다른 글

[B1541][잃어버린 괄호][C++]  (0) 2021.06.25
[B11659][구간 합 구하기 4][C++]  (0) 2021.06.24
[B1260][DFS와 BFS][C++]  (0) 2021.06.23
[B17219][비밀번호 찾기][C++]  (0) 2021.06.21
[B9461][파도반 수열][C++]  (0) 2021.06.18