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 Go (1.14.1) (judge verdict: Accepted)

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := SScan(n)
	x := make([][3]int, n)
	for i := 0; i < n; i++ {
		f := false
		c := 0
		m := []string{}
		for _, v := range a[i] {
			if string(v) == "." {
				f = true
			} else {
				m = append(m, string(v))
				if f {
					c++
				}
			}
		}
		y := stringToInt(strings.Join(m, ""))
		x[i] = [3]int{0, 0, c}
		for y%2 == 0 {
			x[i][0]++
			y /= 2
		}
		for y%5 == 0 {
			x[i][1]++
			y /= 5
		}
		x[i][0] = smaller(18, x[i][0])
		x[i][1] = smaller(18, x[i][1])
	}
	d := make(map[[3]int]int)
	for _, v := range x {
		d[v]++
	}
	ans := 0
	key := make([][3]int, 0, len(d))
	for k, v := range d {
		key = append(key, k)
		p := smaller(k[0]*2, k[1]*2)
		q := k[2] * 2
		if p >= q {
			ans += (v*v - v) / 2
		}
	}
	for i := 0; i < len(key); i++ {
		for j := i + 1; j < len(key); j++ {
			k := key[i]
			l := key[j]
			v := d[k]
			w := d[l]
			p := smaller(k[0]+l[0], k[1]+l[1])
			q := k[2] + l[2]
			if p >= q {
				ans += v * w
			}
		}
	}
	fmt.Println(ans)
}
func PrimeFactors(n int) (pfs []int) {
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}
	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}
	if n > 2 {
		pfs = append(pfs, n)
	}
	return
}