0w1

Double and long double

There are many problems that require high precision mathematical operations that we need to implement big number functions. However, sometimes we could avoid this by making use of double and long double, and perhaps some cmath library functions. 

- POJ 2109 Power of Cryptography -- given n ( 1 <= n <= 200 ), p ( 1 <= p <= 10^101 ), find k such that k^n = p. ( realise that k does not require too much accuracy to be right )

- POJ 1423 Big Number: Given N, output the number of digits of N! ( consider log10 )

- CF #339 Div2 pA Link/Cut Tree: given l, r and k (1 ≤ l ≤ r ≤ 10^18, 2 ≤ k ≤ 10^9), output all powers of k in range [ l, r ]. ( observing there would be an overflow when 10^18 * 10^9, recall that long double can store up to 18 to 19 valid numbers and 4932 digits )

 

Here is a little chart:

type            /bit  / valid digits / absolute range

float             32    6~7               10^(-37) ~ 10^38

double         64   15~16            10^(-307) ~10^308
long double 128 18~19            10^(-4931) ~ 10 ^ 4932