문제 접근
소인수분해를 했을 때 2와 5의 쌍이 존재해야 뒷자리가 0으로 끝남
풀이
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class S1676 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
int cnt = 0;
while (N >= 5) {
cnt += N / 5;
N /= 5;
}
System.out.println(cnt);
}
}
'Algorithm' 카테고리의 다른 글
수학 / 백준 9613 GCD 합 (0) | 2025.05.06 |
---|---|
수학 / 백준 2004 조합 0의 개수 (0) | 2025.05.03 |
수학 / 백준 10872 팩토리얼 (0) | 2025.05.01 |
수학 / 백준 6588 골드바흐의 추측 (0) | 2025.04.28 |
수학 / 백준 1929 소수 구하기 (0) | 2025.04.26 |