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

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

#define e9 1000000000LL

// GCC __gcd(long long A, long long B)

ll gcd(ll a, ll b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

ll toNum(char *s) {
  ll p = 0;
  bool f = false;
  ll t = e9;

  while (*s) {
    if (*s == '.') {
      f = true;
    } else {
      if (!f)
        p = p * 10 + e9 * (*s - '0');
      else
        p += t * (*s - '0');
    }
    if (f) t /= 10;
    s++;
  }

  return p;
}

int main() {
  int N;
  char S[30];
  ll counter[20][20] = {};
  pair<int, int> p[SIZE];

  cin >> N;

  for (int i = 0; i < N; i++) {
    scanf("%s", S);
    ll v = toNum(S);
    int c2 = 0, c5 = 0;
    ll v2 = v;
    while (v2 && v2 % 2 == 0) {
      v2 /= 2;
      c2++;
    }
    while (v2 && v2 % 5 == 0) {
      v2 /= 5;
      c5++;
    }
    counter[min(c2, 18)][min(c5, 18)]++;
    p[i] = {min(c2, 18), min(c5, 18)};
  }

  for (int i = 0; i <= 18; i++) {
    for (int j = 17; j >= 0; j--) {
      counter[i][j] += counter[i][j + 1];
    }
  }

  for (int i = 0; i <= 18; i++) {
    for (int j = 17; j >= 0; j--) {
      counter[j][i] += counter[j + 1][i];
    }
  }

  ll ans = 0;

  for (int i = 0; i < N; i++) {
    int a = p[i].first, b = p[i].second;
    ans += counter[18 - a][18 - b];
    ans -= a >= 9 && b >= 9;
  }

  cout << ans / 2 << endl;

  return 0;
}