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

BBP Formula

Time Limit: 16000/8000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 672    Accepted Submission(s): 384


Problem Description
In 1995, Simon Plouffe discovered a special summation style for some constants. Two year later, together with the paper of Bailey and Borwien published, this summation style was named as the Bailey-Borwein-Plouffe formula.Meanwhile a sensational formula appeared. That is
$$\pi = \sum_{k=0}^{\infty }\frac{1}{16^{k}}(\frac{4}{8k+1}-\frac{2}{8k+4}-\frac{1}{8k+5}-\frac{1}{8k+6})$$
For centuries it had been assumed that there was no way to compute the n-th digit of $\pi$ without calculating allof the preceding n - 1 digits, but the discovery of this formula laid out the possibility. This problem asks you to
calculate the hexadecimal digit n of $\pi$ immediately after the hexadecimal point. For example, the hexadecimalformat of n is 3.243F6A8885A308D313198A2E ... and the 1-st digit is 2, the 11-th one is A and the 15-th one is D.
 

Input
The first line of input contains an integer T (1 ≤ T ≤ 32) which is the total number of test cases.
Each of the following lines contains an integer n (1 ≤ n ≤ 100000).
 

Output
For each test case, output a single line beginning with the sign of the test case. Then output the integer n, andthe answer which should be a character in {0, 1, · · · , 9, A, B, C, D, E, F} as a hexadecimal number
 

Sample Input
5 1 11 111 1111 11111
 

Sample Output
Case #1: 1 2 Case #2: 11 A Case #3: 111 D Case #4: 1111 A Case #5: 11111 E
 

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-04-25 16:24:10, Gzip enabled