
To solve this problem, we need to determine if the factorial of a given integer n ends with exactly k trailing zeros. The number of trailing zeros in a factorial is determined by the number of times 10 is a factor in the product sequence from 1 to n. Since 10 is composed of 2 and 5, we count pairs of these factors.
Approach
- Understanding Trailing Zeros: The number of trailing zeros in
n!(factorial ofn) is determined by the number of times 5 is a factor in the numbers from 1 ton. This is because there are usually more factors of 2 than 5. - Counting Factors of 5: We count how many times 5 appears as a factor in the product sequence. This is done by summing the integer divisions of
nby increasing powers of 5 (i.e., 5, 25, 125, etc.) until the division result is zero. - Comparison with k: If the count of trailing zeros from the above step equals
k, we return "YES"; otherwise, we return "NO".
Solution Code
python
n, k = map(int, input().split())
count = 0
current_divisor = 5
while current_divisor
返回免费演讲稿列表
