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# (.NET Core 3.1.201) (judge verdict: Wrong Answer)

using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        int N = RInt();
        var A = new double[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = RDouble();
        }
        var B = new List<(int, int)>();
        int b2 = 14, b5 = 6;
        var elements = new long[29, 13];// 14=0, 6 = 0
        for (int i = 0; i < N; i++)
        {
            A[i] *= Pow(2, 14) * Pow(5, 6);
            if (IsInteger(A[i]) == false) continue;

            int ele2 = -14, ele5 = -6;
            while (IsInteger(A[i] / 2)) { A[i] /= 2;ele2++; }
            while (IsInteger(A[i] / 5)) { A[i] /= 5;ele5++; }

            elements[Min(28, ele2 + b2), Min(12, ele5 + b5)]++;
            B.Add((Min(28, ele2 + b2), Min(12, ele5 + b5)));
        }

        for (int i = 0; i < 29; i++)
        {
            for (int j = 13 - 1; j >= 1; j--)
            {
                elements[i, j - 1] = elements[i, j] + elements[i, j - 1];
            }
        }
        for (int j = 0; j < 13; j++)
        {
            for (int i = 29 - 1; i >= 1; i--)
            {
                elements[i - 1, j] = elements[i, j] + elements[i - 1, j];
            }
        }
        long ans = 0;
        for (int i = 0; i < B.Count; i++)
        {
            var rev1 = -(B[i].Item1 - b2) + b2;
            var rev2 = -(B[i].Item2 - b5) + b5;
            if (rev1 <= B[i].Item1 && rev2 <= B[i].Item2) ans--;
            ans += elements[rev1,rev2];
        }
        WriteLine(ans/2);
    }
    static bool IsInteger(double a)
    {
        return a % 1 == 0;
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}