Factorial
InterviewTime limit1sMemory limit512 MB
Given N and a prime A, find the largest k such that A^k divides N! (the exponent of A in the prime factorization of N!).
- Level
Easy3 of 10
- Topics
- Number theory, Math, Implementation
- Solved
- No attempts yet
Problem
음이 아닌 정수 N와 소수(prime number) A가 주어지면, N!을 Ak로 나누었을 때, 나머지가 0이 되는 최대의 음이 아닌 정수 k를 구하여라. (단, N!=N×(N-1)×···×1, 0!=1)
Input
첫째 줄에 정수 N과 A가 사이에 공백을 두고 주어진다. (0 ≤ N < 231, 2 ≤ A ≤ 11, A는 소수)
Output
첫째 줄에 최대의 음이 아닌 정수 k를 출력한다.