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>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <char cmp = '<'>
    bool icmp(ll a, ll b){ if(cmp=='>') return a > b; else return a < b;}
namespace enhanced_pair{
    typedef pair<ll,ll> pll;
    ostream& operator << (ostream& o, const pll a){
        o<<a.first<<" "<<a.second;
        return o;
    }
    istream& operator >> (istream& i, pll& p){
        i>>p.first>>p.second;
        return i;
    }
    template <char cmp1 = '<', char cmp2 = '<'>
        bool pcmp(pll a, pll b){ return icmp<cmp1> (a.first,b.first) || (a.first==b.first && icmp<cmp2> (a.second,b.second));}
    template <char cmp1 = '<', char cmp2 = '<'>
        struct pcmpobj{bool operator()(pll a, pll b){return pcmp<cmp1,cmp2>(a,b);}};
} using namespace enhanced_pair;
const ll BIG = 1e18;
const ll NMAX = 2e5+5;
const ll MOD = 1e9+7;
pll v[NMAX];
pll tofraction(string x){
    ll n=0,p2=0,p5=0,p10=0;
    bool point=0;
    for(ll i=0;i<x.size();i++)
        if(x[i]!='.')
            n=n*10+x[i]-'0';
    for(ll i=0;i<x.size();i++){
        if(point==1) p10++;
        if(x[i]=='.') point=1;
    }
    while(n && n%2==0){
        n/=2;
        p2++;
    }
    while(n && n%5==0){
        n/=5;
        p5++;
    }
    return {p2-p10,p5-p10};
}
map<pll,ll> cntatleast;
void tc(){
    ll n,ans=0;
    string x;
    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>x;
        v[i]=tofraction(x);
        for(ll n1=-17;n1<=v[i].first;n1++)
            for(ll n2=-17;n2<=v[i].second;n2++)
                cntatleast[{n1,n2}]++;
    }
    for(ll i=0;i<n;i++){
        ans+=cntatleast[{-v[i].first,-v[i].second}]-(v[i].first>=0 && v[i].second>=0);
    }
    cout<<ans/2;
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //ll q; cin>>q; while(q--)
        tc();

    return 0;
}