Problem:
Score : 300 points

Problem Statement

You are given N real values A_1, A_2, \ldots, A_N.
Compute the number of pairs of indices (i, j)
such that i < j and the product A_i \cdot A_j is integer.

Constraints

2 \leq N \leq 200\,000

0 < A_i < 10^4

A_i is given with at most 9 digits after the decimal.

Input

Input is given from Standard Input in the following format.

N
A_1
A_2
\vdots
A_N

Output

Print the number of pairs with integer product A_i \cdot A_j (and i < j).

Sample Input 1

5
7.5
2.4
17.000000001
17
16.000000000

Sample Output 1

3

There are 3 pairs with integer product:

7.5 \cdot 2.4 = 18

7.5 \cdot 16 = 120

17 \cdot 16 = 272

Sample Input 2

11
0.9
1
1
1.25
2.30000
5
70
0.000000001
9999.999999999
0.999999999
1.000000001

Sample Output 2

8

Solution in Rust (1.42.0) (judge verdict: Wrong Answer)

use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;
#[derive(Clone, Debug, Default)]
struct Struct;


//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        mut f: [f64;n],
    }

    const PMAX:usize = 64;

    let mut v25 = vec![vec![0;PMAX];PMAX];
    // y = a * 1000000000.0
    // ai*ajが整数 -> yi*yjが2^18でも5^18でも割り切れる
    // v25[i][j] : y = 2^i * 5^j * a, a%2!=0, a%5!=0 となるyの個数 
    for x in &f {
        let mut y = (*x * 1000_000_000.0).round() as i64;
        let mut c2 = 0;
        let mut c5 = 0;
        while y % 2 == 0 {
            c2 += 1;
            y /= 2;
        }
        while y % 5 == 0 {
            c5 += 1;
            y /= 5;
        }
        v25[c2][c5] += 1;
        //println!("{} {} ", c2, c5 );
    }

    let mut acc25 = v25.clone(); // acc25[i][j] は  y % (2^i * 5^j) == 0 となる yの個数 
    for i in 0..PMAX {
        for j in 1..PMAX {
            acc25[i][PMAX-j-1] += acc25[i][PMAX-j];
        }
    }
    for i in 0..PMAX {
        for j in 1..PMAX {
            acc25[PMAX-j-1][i] += acc25[PMAX-j][i];
        }
    }

    let mut ans = 0;
    for p2 in 0..PMAX {
        for p5 in 0..PMAX {
            let q2 = if p2 > 18 { 0 } else { 18-p2 };
            let q5 = if p5 > 18 { 0 } else { 18-p5 };
            let sub = if p2 >= 9 && p5 >= 9 {1} else {0}; // 自分自身との組み合わせを除く
            ans += v25[p2][p5] * (acc25[q2][q5]-sub);

            //if v25[p2][p5] != 0 {
            //    println!("p2={} p5={} v={} acc={}", p2, p5, v25[p2][p5], acc25[q2][q5]);
            //}
        }
    }

    println!("{}", ans/2);
}