#P8652. Decimal Extraction in Integer Division
Decimal Extraction in Integer Division
Decimal Extraction in Integer Division
Given two integers (a) and (b) representing a division (\frac{a}{b}) and a positive integer (n), consider the decimal representation of the division. Note that when performing integer division, the result might be a finite decimal or a repeating decimal. By convention, if the division yields a finite number of decimal digits, the decimal is extended by appending an infinite sequence of zeros, so that every result has a uniform representation.
The task is to output the 3-digit number that appears in the decimal expansion starting from the (n)-th digit after the decimal point.
For example, for (a = 1,\ b = 2,\ n = 1), we have (\frac{1}{2} = 0.5000\ldots) and the output is (500).
inputFormat
The input consists of three integers (a), (b), and (n) separated by spaces on a single line. Here, (a) and (b) denote the dividend and divisor respectively, and (n) ((n \geq 1)) is the starting position (1-indexed) after the decimal point from which 3 digits are to be extracted.
outputFormat
Output a 3-digit number representing the three consecutive digits of the decimal expansion of (\frac{a}{b}) starting from the (n)-th digit after the decimal point. If necessary, treat the decimal expansion as infinite by appending zeros for finite decimals.
sample
1 2 1
500