#P9218. Summing Minimum Decimal Precision
Summing Minimum Decimal Precision
Summing Minimum Decimal Precision
You are given n decimal numbers \(a_1, a_2, \dots, a_n\). Each number is represented in decimal notation and has a nonzero fractional part (i.e. it contains a decimal point with a nonzero part following it).
For any number \(a\), define its precision \(f(a)\) to be the smallest nonnegative integer \(k\) such that \(10^k \times a\) is an integer; by convention, if \(a\) is an integer, then \(f(a)=0\). For any two decimal numbers \(a\) and \(b\), define \[ g(a,b)=\min\{ f(c) : c \in [\min(a,b),\; \max(a,b)] \}\,. \]
Your task is: For every \(1 \le i \le n\), compute and output the sum \[ S_i = \sum_{j=1}^n g(a_i,a_j)\,. \]
Note: Even though the definition of a decimal number requires both an integer part and a nonzero fractional part, the definition of the precision function \(f(\cdot)\) has been extended to integers by setting \(f(a)=0\) when \(a\) is an integer. Also note that when the interval \([\min(a,b),\max(a,b)]\) contains an integer, then \(g(a,b)=0\) (since there exists some \(c\) in the interval with \(f(c)=0\)).
inputFormat
The first line contains a positive integer \(n\) (the number of decimal numbers). Each of the following \(n\) lines contains a decimal number \(a_i\) (each having a decimal point and a nonzero fractional part).
outputFormat
Output \(n\) lines. The \(i\)th line should contain the value of \(S_i = \sum_{j=1}^n g(a_i,a_j)\).
sample
3
0.12
0.123
1.1
4
5
1