DMOPC '19 Contest 6 P2 - Grade 10 Math

View as PDF

Submit solution


Points: 7
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Counting is very difficult so Veshy asks you for help. You are given two positive integers, a and b. You want to find the highest power of a, n, that will divide into b!. In other words, you want to find the maximum n such that an divides into b!.

Input Specification

The input is a single line containing two space-separated integers, a and b in that order. 2a<b106

Output Specification

Output on a single line, the number n such that an divides into b! and n is the greatest possible.

Sample Input 1

Copy
8 849

Sample Output 1

Copy
281

Sample Input 2

Copy
2 2020

Sample Output 2

Copy
2013

Explanation

In sample input 1, 8281 is the highest power of 8 that can divide into 849!.
In sample input 2, 22013 is the highest power of 2 that can divide into 2020!.


Comments

There are no comments at the moment.