[백준] P2004

동민·2021년 3월 11일
0
import java.util.Scanner;

public class P2004 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n, m, m2, temp, result, j, count;
		n = sc.nextLong();
		m = sc.nextLong();
		temp = 1;
		for (int i = 0; i < m; i++) {
			temp *= n;
			n -= 1;
		}
		m2 = factorial(m);
		result = temp / m2;
		j = 10;
		count = 0;
		while (result % j == 0) {
			count++;
			j *= 10;
		}
		System.out.println(count);
		sc.close();
	}

	public static long factorial(long m) {
		if (m <= 1) {
			return 1;
		} else {
			return factorial(m - 1) * m;
		}
	}
}
profile
BE Developer

0개의 댓글