Dividing
Time limit1sMemory limit128 MB
For each case with t, a, b, decide whether (t^a-1)/(t^b-1) is an integer below 100 digits, and print it or a fixed message.
- Level
Medium6 of 10
- Topics
- Number theory, Math, Implementation, String matching
- Solved
- No attempts yet
Problem
You are given positive integers , , and , each at most . For each query, determine whether is an integer that has fewer than digits. If it is such an integer, output its value; otherwise output the fixed message described below.
Input
The input consists of several test cases. Each test case is a single line containing three integers , , and separated by spaces. Input continues until end of file (EOF).
Output
Print one line per test case. First print the expression string (t^a-1)/(t^b-1) with , , and replaced by the given values, then a single space, then the result. If is an integer with fewer than digits, print its value; otherwise print is not an integer with less than 100 digits.