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++ (GCC 9.2.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
using namespace std;
#define int long long
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N; cin>>N;
    vector<double> A(N);
    rep(i,N)cin>>A.at(i);

    vec_int Abig(N);
    rep(i,N)Abig.at(i) = (int)(A.at(i)*pow(10,9));


    vector<vector<int>> aa(19,vector<int>(19,0));

    rep(i,N){
        int index2 = 0;
        int Anum = Abig.at(i);
        while(true){
            if(Anum%2==0){
                Anum = Anum/2;
                index2++;
                continue;
            }else{
                break;
            }
        }
        int index5 = 0;
        int Anum2 = Abig.at(i);
        while(true){
            if(Anum2%5==0){
                Anum2 = Anum2/5;
                index5++;
                continue;
            }else{
                break;
            }
        }
        if(index2>18)index2=18;
        if(index5>18)index5=18;
        aa.at(index2).at(index5) +=1;
    }
    int tot_num = 0;
    for(int num2=0;num2<19;num2++){
    for(int num5=0;num5<19;num5++){
        int temp = aa.at(num2).at(num5);

        int ind = 0;
        for(int i =18-num2;i<19;i++){
        for(int j =18-num5;j<19;j++){
            if(num2==9&&num5==9&&i==9&&j==9)continue;
            ind += aa.at(i).at(j);
        }
        }
        tot_num += ind*temp;

    }
    }
    tot_num = tot_num/2;

    for(int num2=9;num2<19;num2++){
    for(int num5=9;num5<19;num5++){
        tot_num += aa.at(num2).at(num5)*(aa.at(num2).at(num5)-1)/2;
    }
    }
    cout<<tot_num<<endl;




    return 0;
}