Book Game with Chef
All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian as well.
Chef gives you a book with N pages. The pages are numbered from 1 to N.
Chef randomly selects a Secret Digit from 0 to 9. Now he asks you to open one page of the book without looking at the book. You win the game if that page number contains the Secret Digit. For example if the Secret Digit is 8, then 8, 80, 1238213, 98 are all winning pages and 9, 90, 1239123 are loosing pages.
What is the probability of winning, if both Chef's choice and your choice has uniform distribution?
The first line of input contains integer T, denoting the number of test cases.
Each test case consists of a single line with integer N.
For each test case, output the required probability P/Q. P/Q is an irreducible fraction.
- 1 ≤ T ≤ 10000
- 1 ≤ N ≤ 1017
Input: 2 1 5 Output: 1/10 1/10
Chef can choose any Secret Digit from 0 to 9. But you can only open page with number 1. Probability that the Secret Digit is 1 after you opened the page with number 1 is 1/10.
|Tags||anudeep2011, cook46, dynamic-programming, easy-medium|
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions