PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GL0000205. Số mũ lớn nhất chia hết giai thừa (Again Prime? No Time.)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Số mũ lớn nhất chia hết giai thừa (Again Prime? No Time.)
Số mũ lớn nhất chia hết giai thừa (Again Prime? No Time.)
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
Given integers and , find the largest integer such that divides . If does not divide , output exactly Impossible to divide. Do not output zero.
Input
One line containing and , in that order.
Output
Print , or Impossible to divide.
Subtasks
-
Subtask 1 (20 points): ; .
-
Subtask 2 (30 points): ; .
-
Subtask 3 (50 points): ; .
Examples
Example 1
Input
2 10
Output
8
Explanation
The exponent of 2 in 10! is 5+2+1=8.
Example 2
Input
4999 2
Output
Impossible to divide
Explanation
4999 does not divide 2!, hence no positive exponent exists.
Example 3
Input
2 100
Output
97
Explanation
The exponent of 2 in 100! is 50+25+12+6+3+1=97.