Ones
Time limit1sMemory limit128 MB
Given p and n, count how many times 2 and 3 divide the repunit 1 + p + ... + p^(n-1) in base p.
- Level
Hard8 of 10
- Topics
- Number theory, Math
- Solved
- No attempts yet
Problem

Let be the natural number whose representation in base consists of the digit repeated times in a row. In other words,
Find the greatest exponents of and of that divide . That is, write a program that finds the largest integer with and the largest integer with .
Input
The first line contains two natural numbers and separated by a space. (, )
Output
Print two non-negative integers separated by a space: the greatest exponent of that divides , followed by the greatest exponent of that divides .