#B4155. Secure Six-Digit Password Transmission

    ID: 11812 Type: Default 1000ms 256MiB

Secure Six-Digit Password Transmission

Secure Six-Digit Password Transmission

In order to enhance security when transmitting passwords over WeChat, Xiao Ming proposes a scheme to send a six-digit password. He sends his friend two integers \(a\) and \(b\) along with 6 unordered positive integers. These 6 integers represent positions in the fractional part of the quotient obtained by \(\frac{a}{b}\) (i.e. the digits after the decimal point). The password is formed by concatenating the digits found at these positions (in the order they are provided).

For example, if \(a=10\) and \(b=3\), the quotient is \(3.33333...\). Suppose the six unordered positions provided are: 1, 2, 3, 4, 5, 6. Then the password is 333333 since the first six digits after the decimal are all 3. If the fraction terminates (e.g. \(\frac{5}{2}=2.5\)), assume that missing digits are 0 (i.e. treat the fractional part as if it were filled with an infinite sequence of 0's).

Note: It is recommended to simulate the division process to extract the required digits without floating-point precision issues. Use the long division method to compute up to the maximum required digit position.

inputFormat

The input consists of two lines:

  1. The first line contains two integers \(a\) and \(b\) separated by a space.
  2. The second line contains 6 positive integers, representing the positions (after the decimal point) whose digits are used to form the password. The positions are given in an arbitrary order.

If the fractional part of \(\frac{a}{b}\) is shorter than the highest requested position, assume the missing digits are 0.

outputFormat

Output the six-digit password, which is the concatenation of the digits located at the specified positions in the fractional part of \(\frac{a}{b}\).

The output is a single string of six characters (each character is a digit from 0-9).

sample

10 3
1 2 3 4 5 6
333333