The 11th Blue Bridge Cup Graduate Group National Competition - Recurring Decimals (Number Theory)

The 11th Blue Bridge Cup Graduate Group National Competition-Cyclic Decimals

1. Description of the topic

  Given that S is a recurring decimal less than 11, please calculate the simplest true fraction equal to S.

  For example, 0.3333⋯0.3333⋯ is equal to 1331, and 0.1666⋯0.1666⋯ is equal to 1661.

enter description

  The first line of input contains two integers p and q , indicating that the cyclic section of S is from the pth to the qth digit after the decimal point.

  The second line contains a q- digit number representing the first q digits of the fractional part of S.

  Among them, 1≤ pq ≤ 10.

output description

  Output two integers, separated by a space, representing the numerator and denominator of the answer, respectively.

Input and output samples

Example 1

enter

1 6
142857

Guess you like

Origin blog.csdn.net/qq_43753724/article/details/130500812