F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Fraction

Time 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. It is guaranteed that the limit always exists.

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
2 7 1 2 1 1 1
 

Sample Output
Case #1: 0.05799 Case #2: 1.00000
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-06-24 21:46:42, Gzip enabled