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: Accepted)

using System;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using System.Collections.Generic;

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;


    void calc()
    {
        int N = cin.nextInt();
        int[] num2 = new int[N];
        int[] num5 = new int[N];

        int MAX = 18;
        int[,] sum = new int[MAX + 2, MAX + 2];

        for (int i = 0; i < N; i++)
        {
            string S = cin.next();
            int pnum = -1;
            long now = 0;

            foreach (var c in S)
            {
                if(c == '.')
                {
                    pnum = 0;
                }
                else
                {
                    now *= 10;
                    now += (c - '0');
                    if (pnum >= 0) pnum++;
                }
            }

            if (pnum == -1) num2[i] = num5[i] = MAX / 2;
            else num2[i] = num5[i] = MAX / 2 - pnum;

            while(now % 2 == 0)
            {
                now /= 2; num2[i]++;
            }
            while(now % 5 == 0)
            {
                now /= 5; num5[i]++;
            }
            num2[i] = Math.Min(MAX, num2[i]);
            num5[i] = Math.Min(MAX, num5[i]);

            sum[num2[i], num5[i]]++;
        }

        for (int i = MAX; i >= 0; i--)
        {
            for (int j = MAX; j >= 0; j--)
            {
                sum[i, j] += sum[i + 1, j];
                sum[i, j] += sum[i, j + 1];
                sum[i, j] -= sum[i + 1, j + 1];
            }
        }

        long ans = 0;
        for (int i = 0; i < N; i++)
        {
            int need2 = MAX - num2[i];
            int need5 = MAX - num5[i];
            ans += sum[need2, need5];
            if (need2 <= MAX / 2 && need5 <= MAX / 2) ans--;

        }

        ans /= 2;

        Console.WriteLine(ans);
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}