A Plus B Again!
All submissions for this problem are available.
Have you ever implemented a program adding two big integers that cannot be represented by the primitive data type of your programming language? The algorithm is just simulation of the column addition method that we have been taught in elementary school. Sometimes we forget the carry and the result is incorrect.
In this problem, you need to evaluate the expected value of the number of times we have non-zero carry when adding two non-negative integers that contain at most N digits each. Note that we are adding the numbers in their base 10 representation.
For example, the following table shows the number of carries when adding some pairs of numbers:
|A||B||Number of carries|
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
Each test case has a single line containing an integer N.
For each test case, output a single line containing the required expected value.
Your answer will be accepted if the error is less than 10 -6.
- 1 ≤ T ≤ 100,000(105)
- 1 ≤ N ≤ 100,000(105)
Input: 3 1 2 3 Output: 0.45 0.945 1.4445
Example case 1.
We have 10*10 = 100 cases of adding two 1-digit number.
The carry appears when adding 1 and 9, 2 and 9, 3 and 9 ... and so on,
there are 45 cases in total and in each case, the carry appears exactly once.
|Tags||cook36, easy, maths, probability, tsaplusb, tuananh93|
|Time Limit:||1 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, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.