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 "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// const int MOD = 998244353;
// const int MOD = 1000000007;
vector<pii> p;
/*----------------------------------------------------------------*/
signed main(){
	
	int n;
	cin >> n;
	int cnt[300][300] = {};
	rep(i,n){
		string a;
		cin >> a;
		// cerr << a << endl;
		int m = a.size();
		int z = 0;
		int f = 0;
		int x2 = 0;
		int x5 = 0;

		rep(j,m){
			if(a[m-1-j] == '.'){
				f = 1;
				a.erase(m-1-j,1);
				break;
			}else{
				z++;
			}
		}
		if(f==0)z = 0;
		
		x2 = -z;
		x5 = -z;
		cerr << a << endl;
		int A = stoll(a);
		while(A%2 == 0){
			A /= 2;
			x2++;
		}
		while(A%5 == 0){
			A /= 5;
			x5++;
		}
		p.push_back(MP(x2,x5));
		// cerr << x2 <<" " << x5 << endl;
		cnt[x2+150][x5+150]++;
	}

	int s[310][310] = {};
	rep(i,301)rep(j,301)s[i+1][j+1] = s[i+1][j] + s[i][j+1] - s[i][j] + cnt[i][j];

	int ans = 0;
	rep(i,n){
		int x2 = p[i].first;
		int x5 = p[i].second;
		// cerr << x2 << " " << x5 << endl;
		int y2 = 150-x2;
		int y5 = 150-x5;
		int pl = s[300][300]-s[y2][300]-s[300][y5]+s[y2][y5];
		if(x2>=0&&x5>=0)pl--;
		ans += pl;
		// cerr << x2 <<" " << x5 << " : " << pl << endl;
	}
	cout << ans/2 << endl;
	


	


	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://abc174.contest.atcoder.jp/tasks/abc174_b
// rm -r -f test;oj d https://atcoder.jp/contests/agc047/tasks/agc047_a