![]() |
||||||||||
|
||||||||||
FractionTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 733 Accepted Submission(s): 253 Problem Description Given a number n, and a geometric progression ai = b * qi, i ≥ 0, what is the fraction of the elements of that progression with decimal notation that has the decimal notation of n as prefix ? More formally, if ci out of the first i elements of the progression start with n in decimal notation, you need to find the limit ![]() For example, n = 7, b = 1, q = 2. About 5.799% of all powers of two start with 7. (the smallest one is 246 = 70368744177664) Input The first line of the input is T (1 ≤ T ≤ 100), which stands for the number of test cases you need to solve. Each case contains three integers n,b and q. (1 ≤ n, b, q ≤ 1000) Output For each test case, print a line “Case #t: ”(without quotes, t means the index of the test case) at the beginning. Then output one floating number – the sought fraction. Round your answer to the 5th decimal place. Sample Input
Sample Output
Source | ||||||||||
|