Gargle
Time limit1sMemory limit128 MB
Print base-7 digits of N/D from position B through E after the radix point, with leading zeros preserved.
- Level
Medium4 of 10
- Topics
- Math, Simulation, Implementation
- Solved
- No attempts yet
Problem
Google once put up the following billboard along Highway 101, which runs through the heart of Silicon Valley:
"{first 10-digit prime found in consecutive digits of }.com"
Deeply impressed by this recruiting stunt, a mouthwash company named Gargle decided to hire people with the following problem:
"{the digits of a certain rational number written in base 7, from the -th digit through the -th digit after the radix point}.com"
For example, (in base 10) written in base 7 is , is , and is .
Given a rational number , write a program that prints its base-7 digits from the -th digit through the -th digit after the radix point.
Input
The first line contains the number of test cases .
Each test case is given on a single line as four base-10 integers , , , and separated by spaces. and are the numerator and denominator of the rational number, with and . and give the range of digit positions to output, with and .
The -th digit after the radix point is the digit immediately to the right of the point.
Output
For each test case, print one line in the following format:
Problem set k: N / D, base 7 digits B through E: result
Here is the test case number (starting from 1), is the computed digit string, and the other values , , , are those given in the input. Leading zeros in are printed as-is.