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 C# (Mono-mcs 6.8.0.105) (judge verdict: Time Limit Exceeded)

using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		double[]A = new double[N];
		var dic = new Dictionary<string,int>();
		for(var i=0;i<N;i++){
			string s = Console.ReadLine();
             A[i] = double.Parse(s);
			int c10 = 0;
          	while(s.IndexOf(".")!=-1){
				if(s.Substring(0,2)=="0."){
                  	s = s.Replace("0.",".");
                }
				if(s.IndexOf(".")==s.Length-2){
                  	s = s.Replace(".","");
                } else {
                    s = s.Substring(0,s.IndexOf("."))+s.Substring(s.IndexOf(".")+1,1)+"."+s.Substring(s.IndexOf(".")+2,s.Length-s.IndexOf(".")-2);
                }
              	c10--;
            }
			int c5 = 0;
			int c2 = 0;
			long d = long.Parse(s);
			while(d%5==0){
				d /= 5;
				c5++;
			}
			while(d%2==0){
				d /= 2;
				c2++;
			}
			string dai =c10+"a"+c5+"b"+c2;
			if(dic.ContainsKey(dai)){
              	dic[dai]++;
            } else {
              	dic[dai] = 1;
            }
		}
      	long ansct = 0;
		foreach(var dab in dic.Keys){
 			string s1 = dab.Substring(0,dab.IndexOf("a"));
          	long a1 = long.Parse(s1);
 			string s2 = dab.Substring(dab.IndexOf("a")+1,dab.IndexOf("b")-dab.IndexOf("a")-1);
          	long a2 = long.Parse(s2);
 			string s3 = dab.Substring(dab.IndexOf("b")+1,dab.Length-dab.IndexOf("b")-1);
          	long a3 = long.Parse(s3);
          	//Console.WriteLine(dic[dab]+" "+a1+" "+a2+" "+a3);
			foreach(var dac in dic.Keys){
 			string s4 = dac.Substring(0,dac.IndexOf("a"));
          	long b1 = long.Parse(s4);
 			string s5 = dac.Substring(dac.IndexOf("a")+1,dac.IndexOf("b")-dac.IndexOf("a")-1);
          	long b2 = long.Parse(s5);
 			string s6 = dac.Substring(dac.IndexOf("b")+1,dac.Length-dac.IndexOf("b")-1);
          	long b3 = long.Parse(s6);
              //Console.WriteLine(dic[dab]+" "+b1+" "+b2+" "+b3);
              	if(a2+b2>=-a1-b1 && a3+b3>=-a1-b1){
					if(dab==dac){
                      	ansct += (long)(dic[dab]-1)*dic[dac];
                    } else {
                      	ansct += (long)dic[dab]*dic[dac];
                    }
                }
            }
        }
		Console.WriteLine(ansct/2);
	}
}