DMOPC '19 Contest 6 P2 - Grade 10 Math
View as PDFCounting is very difficult so Veshy asks you for help. You are given two positive integers,  and 
. You want to find the highest power of 
, 
, that will divide into 
. In other words, you want to find the maximum 
 such that 
 divides into 
.
Input Specification
The input is a single line containing two space-separated integers,  and 
 in that order. 
Output Specification
Output on a single line, the number  such that 
 divides into 
 and 
 is the greatest possible.
Sample Input 1
8 849
Sample Output 1
281
Sample Input 2
2 2020
Sample Output 2
2013
Explanation
In sample input 1,  is the highest power of 
 that can divide into 
.
In sample input 2,  is the highest power of 
 that can divide into 
.
Comments