Decimal Help
Practice
3.9 (9 votes)
Ad Hoc
Mathematics
Easy
Problem
36% Success 4261 Attempts 20 Points 2s Time Limit 256MB Memory 1024 KB Max Code

Bosky often helps his younger brother Nitin with his home work and also clears his doubts.

Today, Nitin learned about proper fractions. He went a step forward and tried to represent the same proper fraction in its decimal form, but runs into problems. He now seeks help from his brother Bosky.

Nitin is a very sincere learner, thus he wants his brother to help him but doesn't want him to completely solve the problem. He goes to his brother Bosky and asks him to help him wherever he gets stuck while representing the proper fraction in decimal expansion by telling the next digit in the decimal expansion.

Though Bosky is a bit busy today with his school project, he doesn't want to disappoint his brother. He is familiar with your brilliant programming skills and asks you to create a program to help his brother, which can output R \(th\) digit in the decimal expansion for a given proper fraction \(\frac{N}{D}\).

Input:

Input will contain a number T denoting the number of test cases.

Then T test cases follow, each one consisting 3 integers N D R where N and D are numerator and denominator respectively.

Output

For each test case, output a single integer representing R \(th\) digit from the left in the decimal expansion.

NOTE: The number is a proper fraction, hence the counting will always start after the decimal place. For eg. fraction \(\frac{1}{2}\) can be written as \(0.5\) so its first digit is 5 and all the digits after 5 are 0.

Constraints

\(1 \le T \le 100\)

\(1 \le N \le D \le 1000000\)

\(1 \le R \le 1000000\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
89 votes
Tags:
ApprovedBasic ProgrammingDynamic ProgrammingEasyImplementationOpen
Points:10
2431 votes
Tags:
Easy
Points:20
2 votes
Tags:
Easy