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: Wrong Answer)

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.",".");
                }
 				//Console.WriteLine(i+" "+s+" "+s.Length);
				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--;
            }
			//double da = double.Parse(s);
			//while(da%1!=0){
			//	da *= 10;
			//	c10--;
			//}
			int c5 = 0;
			int c2 = 0;
          //Console.WriteLine(s);
			if(true || s.IndexOf(".")==-1){
              	long d = long.Parse(s);
				//long d = (long)da;
              	//Console.WriteLine(s+" "+d);
				while(d%5==0){
					d /= 5;
					c5++;
				}
				while(d%2==0){
					d /= 2;
					c2++;
				}
			}
			//Console.Error.WriteLine(s+" "+c10+" "+c5+" "+c2);
			string dai =c10+"a"+c5+"b"+c2;
			if(dic.ContainsKey(dai)){
              	dic[dai]++;
            } else {
              	dic[dai] = 1;
            }
		}
      	var ansct = 0;
		foreach(var dab in dic.Keys){
          	//Console.WriteLine(dab);
 			string s1 = dab.Substring(0,dab.IndexOf("a"));
          	long a1 = long.Parse(s1);
          //Console.WriteLine(a1);
 			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);
			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);
              	if(a2+b2>=-a1-b1 && a3+b3>=-a1-b1){
				//if(dab[1]+dac[1]>=-dab[0]-dac[0] && dab[2]+dac[2]>=-dac[0]-dab[0]){
 	                if(dab==dac){
                  	//if(dab[0]==dac[0] && dab[1]==dac[1] && dab[2]==dac[2]){
                      	//if((dic[dab]-1)*dic[dac]>0){
                      	//Console.Error.WriteLine(dic[dab]+" "+dic[dac]+" "+dab[0]+" "+dab[1]+" "+dab[2]+" "+dac[0]+" "+dac[1]+" "+dac[2]);
                        //}
                      	ansct += (dic[dab]-1)*dic[dac];
                    } else {
                      //Console.Error.WriteLine(dic[dab]+" "+dic[dac]+" "+dab[0]+" "+dab[1]+" "+dab[2]+" "+dac[0]+" "+dac[1]+" "+dac[2]);
	                 	ansct += dic[dab]*dic[dac];
                    }
                }
            }
        }
		Console.WriteLine(ansct/2);
	}
}