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



Sample input:
5
7.5
2.4
17.000000001
17
16.000000000


Sample output:
3

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce


# 画像でおいた自分の解説見て
N = a_int()
B = []
for _ in ra(N):
    A = float(read()[:-1])  # floatなら小数13桁ぐらい入る
    B.append(int(A * (10**9)))

N = []
M = []
for b in B:
    n = 0
    while b % 2 == 0:  # 偶数である限り
        b >>= 1
        n += 1
    N.append(n)

    m = 0
    while b % 5 == 0:  # 5で割れる限り
        b //= 5
        m += 1
    M.append(m)

cnt = [[0] * 19 for _ in ra(19)]
ans = 0
for n, m in zip(N, M):
    x = max(18 - n, 0)
    y = max(18 - m, 0)
    for i, j in product(range(x, 19), range(y, 19)):
        ans += cnt[i][j]

    # このデータをcntに追加
    cnt[min(n, 18)][min(m, 18)] += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce


# 画像でおいた自分の解説見て
N = a_int()
B = []
for _ in ra(N):
    A = float(read()[:-1])  # floatなら小数13桁ぐらい入る
    B.append(int(A * (10**9)))

N = []
M = []
for b in B:
    n = 0
    while b % 2 == 0:  # 偶数である限り
        b >>= 1
        n += 1
    N.append(n)

    m = 0
    while b % 5 == 0:  # 5で割れる限り
        b //= 5
        m += 1
    M.append(m)

cnt = [[0] * 19 for _ in ra(19)]
ans = 0
for n, m in zip(N, M):
    x = 18 - n
    y = 18 - m
    for i, j in product(range(x, 19), range(y, 19)):
        ans += cnt[i][j]

    # このデータをcntに追加
    cnt[min(n, 18)][min(m, 18)] += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce


# 画像でおいた自分の解説見て
N = a_int()
B = []
for _ in ra(N):
    A = float(read()[:-1])  # floatなら小数13桁ぐらい入る
    B.append(int(A * (10**9)))

N = []
M = []
for b in B:
    n = 0
    while ~b & 1:  # 偶数である限り
        b >>= 1
        n += 1
    N.append(n)

    m = 0
    while b % 5 == 0:  # 5で割れる限り
        b //= 5
        m += 1
    M.append(m)

cnt = [[0] * 19 for _ in ra(19)]
ans = 0
for n, m in zip(N, M):
    x = 18 - n
    y = 18 - m
    for i, j in product(range(x, 19), range(y, 19)):
        ans += cnt[i][j]

    # このデータをcntに追加
    cnt[min(n, 18)][min(m, 18)] += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = [int((float(input())+0.5)*(10**9)) for _ in range(N)]
fac = [[0, 0] for _ in range(N)]

for i, x in enumerate(A):
    while x%2 == 0:
        x //= 2
        fac[i][0] += 1
    while x%5 == 0:
        x //= 5
        fac[i][1] += 1

acc = [[0]*51 for _ in range(51)]

for l in fac:
    n2, n5 = l
    acc[n2+1][n5+1] += 1

acc = np.array(acc, dtype=np.int64)
acc = acc.cumsum(0).cumsum(1).tolist()

ans = 0

for l in fac:
    n2, n5 = l
    n2l = max(0, 18-n2)
    n5l = max(0, 18-n5)
    ans += acc[50][50] - acc[n2l][50] - acc[50][n5l] + acc[n2l][n5l]
    if n2 >= 9 and n5 >= 9:
        ans -= 1

print(ans//2)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = [int(float(input())*(10**9)) for _ in range(N)]
fac = [[0, 0] for _ in range(N)]

for i, x in enumerate(A):
    while x%2 == 0:
        x //= 2
        fac[i][0] += 1
    while x%5 == 0:
        x //= 5
        fac[i][1] += 1

acc = [[0]*51 for _ in range(51)]

for l in fac:
    n2, n5 = l
    acc[n2+1][n5+1] += 1

acc = np.array(acc, dtype=np.int64)
acc = acc.cumsum(0).cumsum(1).tolist()

ans = 0

for l in fac:
    n2, n5 = l
    n2l = max(0, 18-n2)
    n5l = max(0, 18-n5)
    ans += acc[50][50] - acc[n2l][50] - acc[50][n5l] + acc[n2l][n5l]
    if n2 >= 9 and n5 >= 9:
        ans -= 1

print(ans//2)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[[0]*19 for i in range(19)]
for i in range(N):
  a=float(input())
  a*=10**9
  x=int(a)
  tcnt,fcnt=0,0
  while x%2==0 and tcnt<18:
    tcnt+=1
    x=x//2
  while x%5==0 and fcnt<18:
    fcnt+=1
    x=x//5
  A[fcnt][tcnt]+=1

cnt=0
for i in range(19):
  for j in range(19):
    for k in range(19):
      for l in range(19):
        if i+k>=18 and j+l>=18:
          if i!=k and j!=l:
            d=A[i][j]
            e=A[k][l]
            p=d*e
          elif i==k and j==l:
            d=A[i][j]
            p=d*(d-1)
          else:
            d=A[i][j]
            e=A[k][l]
            p=d*e
          cnt+=p
print(cnt//2)

Submission status: Wrong Answer

Solution code:
import sys
import decimal

input = sys.stdin.readline
D = decimal.Decimal


def power_2_5(arg):
    x = int(D(arg) * 10 ** 9)

    for p2 in range(19):
        q, r = divmod(x, 2)
        if r != 0:
            break
        else:
            x = q

    for p5 in range(19):
        q, r = divmod(x, 5)
        if r != 0:
            break
        else:
            x = q

    return p2, p5


N = int(input())
arr = [[0] * 19 for _ in range(19)]
for _ in range(N):
    p2, p5 = power_2_5(input())
    arr[p2][p5] += 1

cum_arr = [[None] * 19 for _ in range(19)]

for i in range(19):
    cum_arr[i][-1] = arr[i][-1]
    cum_arr[-1][i] = arr[-1][i]

for i in range(17, -1, -1):
    for j in range(17, -1, -1):
        cum_arr[i][j] = (
            arr[i][j] + cum_arr[i][j + 1] + cum_arr[i + 1][j] - cum_arr[i + 1][j + 1]
        )

ans = -cum_arr[9][9]
for i in range(19):
    for j in range(19):
        ans += arr[i][j] * cum_arr[18 - i][18 - j]

ans //= 2
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import decimal

input = sys.stdin.readline
D = decimal.Decimal


def power_2_5(arg):
    x = int(D(arg) * 10 ** 9)

    for p2 in range(19):
        q, r = divmod(x, 2)
        if r != 0:
            break
        else:
            x = q

    for p5 in range(19):
        q, r = divmod(x, 5)
        if r != 0:
            break
        else:
            x = q

    return p2, p5


N = int(input())
P = [power_2_5(input()) for _ in range(N)]

arr = [[0] * 19 for _ in range(19)]

for p2, p5 in P:
    arr[p2][p5] += 1

cum_arr = [[None] * 19 for _ in range(19)]

for i in range(19):
    cum_arr[i][-1] = arr[i][-1]
    cum_arr[-1][i] = arr[-1][i]

for i in range(17, -1, -1):
    for j in range(17, -1, -1):
        cum_arr[i][j] = (
            arr[i][j] + cum_arr[i][j + 1] + cum_arr[i + 1][j] - cum_arr[i + 1][j + 1]
        )

ans = -sum(min(pp) >= 9 for pp in P)
for i in range(19):
    for j in range(19):
        ans += arr[i][j] * cum_arr[18 - i][18 - j]

ans //= 2
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import decimal

input = sys.stdin.readline
D = decimal.Decimal


def power_2_5(arg):
    x = int(D(arg) * 10 ** 9)

    for p2 in range(19):
        q, r = divmod(x, 2)
        if r != 0:
            break
        else:
            x = q

    for p5 in range(19):
        q, r = divmod(x, 5)
        if r != 0:
            break
        else:
            x = q

    return p2, p5


N = int(input())
P = [power_2_5(input()) for _ in range(N)]

arr = [[0] * 19 for _ in range(19)]

for p2, p5 in P:
    arr[p2][p5] += 1

cum_arr = [[None] * 19 for _ in range(19)]

for i in range(19):
    cum_arr[i][-1] = arr[i][-1]
    cum_arr[-1][i] = arr[-1][i]

for i in range(17, -1, -1):
    for j in range(17, -1, -1):
        cum_arr[i][j] = (
            arr[i][j] + cum_arr[i][j + 1] + cum_arr[i + 1][j] - cum_arr[i + 1][j + 1]
        )

ans = -cum_arr[9][9]
for i in range(19):
    for j in range(19):
        ans += arr[i][j] * cum_arr[18 - i][18 - j]

ans //= 2
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
c = 0
j = 1
s = 0
for i in range (N):
    A.append(float(input()) * 10)
for j in range (N - 1):
    for c in range (j):
        if (A[c] * A[j] / 100).is_integer() == True:
            s += 1
    i = 0
print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
c = 0
j = 1
s = 0
for i in range (N):
    A.append(float(input()) * 100)
for j in range (N - 1):
    for c in range (j):
        if (A[c] * A[j] / 10000).is_integer() == True:
            s += 1
    i = 0
print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
c = 0
j = 1
s = 0
for i in range (N):
    a = float(input()) * 10
    A.append(a)
for j in range (N - 1):
    for c in range (j):
        if (A[c] * A[j] / 100).is_integer() == True:
            s += 1
    i = 0
print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list()
c = 0
j = 1
s = 0
for i in range (N):
    a = float(input()) * 10
    A.append(a)
for j in range (N - 1):
    C = c
    for c in range (j):
        o = A[c] * A[j] / 100
        if o.is_integer() == True:
            s = s + 1
    c = 0
print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list()
c = 0
j = 1
s = 0
for i in range (N):
    a = float(input()) * 10
    A.append(a)
for j in range (N - 1):
    C = c
    for c in range (j):
        o = A[c] * A[j] / 100
        if o.is_integer() == True:
            s = s + 1
print(s)

Submission status: Wrong Answer

Solution code:
import collections
N, *S = [s + 'z' for s in open(0).read().split()]
S.sort(key=len)
N = int(N[:-1])
cnt = [collections.defaultdict(int) for _ in range(N)]
for i, s in enumerate(S):
    for c in s:
        cnt[i][c] += 1
rollinghash = [0] * N
mod = 2**31 - 1
k = 2**10
j = -1
ans = 0
se = {'z': {range(N)}}
imin = 0
for j in range(-1, -len(S[-1]) - 1, -1):
    for i in range(imin, N):
        if j == -len(S[i]):
            ans += sum(cnt[p][S[i][0]] > 0 for p in se[rollinghash[i]]) - 1
    for i in range(imin, N):
        if j == -len(S[i]):
            imin += 1
        cnt[i][S[i][j]] -= 1
    se = collections.defaultdict(set)
    for i in range(imin, N):
        rollinghash[i] *= k
        rollinghash[i] += ord(S[i][j])
        rollinghash[i] &= mod
        se[rollinghash[i]].add(i)
    j -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())

F=[]
for i in range(N):
  F.append(float(input()))
cnt=0
for j in range(0,N-1):
  A_u = F[j]
  for k in range(j+1,N):
    A_f = A_u*F[k]
    if A_f==int(A_f):
      cnt +=1
print(cnt)

Submission status: Wrong Answer

Solution code:
from math import gcd

def Count_tf(a):
    two,five = 0,0
    while a % 2 == 0:
        two += 1
        a //= 2
    while a % 5 == 0:
        five += 1
        a //= 5
    return (two,five)

def kiyaku(a):
    a = int(a * 10**9)
    g = gcd(a,10**9)
    return (a//g,10**9//g)

def main():
    N = int(input())
    A = [float(input()) for _ in range(N)]

    B,C = [],[]
    for i in range(N):
        ki = kiyaku(A[i])
        B.append(ki[0]) #分子
        C.append(ki[1]) #分母

    D = {}
    ans = 0
    for i in range(N):
        ctfb,ctfc = Count_tf(B[i]),Count_tf(C[i])
        
        if (ctfb[0]-ctfc[0],ctfb[1]-ctfc[1]) in D:
            D[(ctfb[0]-ctfc[0],ctfb[1]-ctfc[1])] += 1
        else:
            D[(ctfb[0]-ctfc[0],ctfb[1]-ctfc[1])] = 1

        if ctfb[0]-ctfc[0] >= 0 and ctfb[1]-ctfc[1] >= 0:
            ans -= 1

    for d1 in D:
        for d2 in D:
            if d1[0] + d2[0] >= 0 and d1[1] + d2[1] >= 0:
                ans += D[d1] * D[d2]

    print(ans//2)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
seisu=[]
shosu=[]
for i in range(n):
	s=input()
	rv={0,0}
	rv = s.split(".");
	seisu.append(int(rv[0]))
	if (len(rv) != 1):
		shosu.append(int(rv[1]) * 10 ** (9 - len(rv[1])))
	else:
		shosu.append(0)

count = 0
for i in range(n):
	for j in range(i):
		if (shosu[i] == 0 and shosu[j] == 0):
			count = count + 1
		elif (shosu[i] == 0 and (seisu[j] * 1000000000 + shosu[j]) * seisu[i] % 1000000000 == 0):
			count = count + 1
		elif (shosu[j] == 0 and (seisu[i] * 1000000000 + shosu[i]) * seisu[j] % 1000000000 == 0):
				count = count + 1

print(str(count))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [float(input()) for _ in range(n)]
a = [i*10**9 for i in a]
MAX = 50
p_mat = [[0 for _ in range(MAX)] for _ in range(MAX)]

for i in a:
    b_cnt = 0
    while i % 2 == 0:
        i /= 2
        b_cnt += 1
    f_cnt = 0
    while i % 5 == 0:
        i /= 5
        f_cnt += 1
    p_mat[b_cnt][f_cnt] += 1

ans = 0
for b1 in range(MAX):
    for f1 in range(MAX):
        for b2 in range(MAX):
            for f2 in range(MAX):
                if b1+b2 >= 18 and f1+f2 >= 18:
                    if b1 == b2 and f1 == f2:
                        ans += p_mat[b1][f1] * (p_mat[b2][f2] - 1)
                    else:
                        ans += p_mat[b1][f1] * p_mat[b2][f2]
print(ans//2)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [float(input()) for _ in range(n)]
a = [i*10**9 for i in a]
MAX = 50
p_mat = [[0 for _ in range(MAX)] for _ in range(MAX)]

for i in a:
    b_cnt = 0
    while i % 2 == 0:
        i /= 2
        b_cnt += 1
    f_cnt = 0
    while i % 5 == 0:
        i /= 5
        f_cnt += 1
    p_mat[b_cnt][f_cnt] += 1

ans = 0
for b1 in range(MAX):
    for f1 in range(MAX):
        for b2 in range(MAX):
            for f2 in range(MAX):
                if b1+b2 >= 18 and f1+f2 >= 18:
                    if b1 == b2 and f1 == f2 and p_mat[b1][f1] > 0:
                        ans += p_mat[b1][f1] * (p_mat[b2][f2] - 1)
                    else:
                        ans += p_mat[b1][f1] * p_mat[b2][f2]
print(ans//2)

Submission status: Wrong Answer

Solution code:
import bisect
N, *A = [float(_) for _ in open(0).read().split()]
N = int(N)
c = [[0, 0] for _ in range(N)]
for i, a in enumerate(A):
    a = int(a * 10**9)
    while True:
        if a % 2:
            break
        c[i][0] += 1
        a //= 2
    while True:
        if a % 5:
            break
        c[i][1] += 1
        a //= 5
c.sort()

#cum[i][j]:c[x][1]>=i (j<=x)となるようなxの個数
cum = [[0] * (N + 1) for _ in range(19)]
for i in range(19):
    for j in range(N - 1, -1, -1):
        cum[i][j] = cum[i][j + 1]
        if c[j][1] >= i:
            cum[i][j] += 1
ans = 0
for i, c2c5 in enumerate(c):
    c2, c5 = c2c5
    if c2 > 9 or (c2 == 9 and c5 >= 9):
        i2 = i + 1
    else:
        i2 = bisect.bisect_left(c, [18 - c2, -1])
    ans += cum[18 - c5][i2]
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
A=[]
PRECISION_DIGITS=9
NO_ENTRY = 0
cnt=np.full((PRECISION_DIGITS*2+1,PRECISION_DIGITS*2+1),NO_ENTRY,int)
# cnt=np.zeros((PRECISION_DIGITS*2,PRECISION_DIGITS*2),int)

# print(cnt)

for n in range(N):
	tmpA = float(input())
	tmpA = round(tmpA*10**PRECISION_DIGITS)
	#print(tmpA)

	five = 0
	two = 0
	# (10**9) -> (two,five)=(9,9)
	# min = 10**-9, ignore < 10**9 ???
	while (tmpA % 5) == 0 and five < PRECISION_DIGITS*2:
		five += 1
		tmpA //= 5
	while (tmpA % 2) == 0 and two < PRECISION_DIGITS*2:
		two += 1
		tmpA //= 2

	if cnt[two][five] == 0:
		cnt[two][five]=1
	else:
		cnt[two][five]+=1

# print(cnt)
ans = 0

for x1 in range(PRECISION_DIGITS*2):
	for y1 in range(PRECISION_DIGITS*2):
		if cnt[x1][y1] == NO_ENTRY:
			continue

		for x2 in range(PRECISION_DIGITS*2):
			for y2 in range(PRECISION_DIGITS*2):
				if cnt[x2][y2] == NO_ENTRY:
					continue
				# 2**a(a>=0) and 5**b(b>=0) => integer
				if 0 <= x1+x2 - PRECISION_DIGITS*2 and 0 <= y1+y2 -PRECISION_DIGITS*2:
					if x1 == x2 and y1 == y2:
						# same entry
						# Total number of combinations choose 2 items
						# nC2 = n*(n-1)/2
						ans += int((cnt[x1][y1]*(cnt[x2][y2]-1))//2)
					else:
						ans += cnt[x1][y1]*cnt[x2][y2]

		# count up completed entry
		cnt[x1][y1] = NO_ENTRY

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[]
PRECISION_DIGITS=9
cnt={}


for n in range(N):
	tmpA = float(input())
	tmpA = tmpA*10**PRECISION_DIGITS
	#print(tmpA)

	five = 0
	two = 0
	while (tmpA % 2) == 0:
		two += 1
		tmpA //= 2
	while (tmpA % 5) == 0:
		five += 1
		tmpA //= 5

	# (10**9) -> (two,five)=(9,9)
	two -= PRECISION_DIGITS
	five -= PRECISION_DIGITS

	if (two,five) in cnt:
		cnt[(two,five)]+=1
	else:
		cnt[(two,five)]=1

keys=sorted(cnt.keys())

# print(cnt)
ans = 0
for t1 in keys:
	for t2 in keys:
		# 2**a(a>=0) and 5**b(b>=0) => integer
		cnt1 = cnt[(t1[0],t1[1])]
		cnt2 = cnt[(t2[0],t2[1])]

		if 0 <= t1[0]+t2[0] and 0 <= t1[1]+t2[1]:
			if t1 < t2:
				ans += int(cnt1*cnt2)
			elif t1 == t2:
				# same entry
				# Total number of combinations choose 2 items
				# nC2 = n*(n-1)/2
				ans += int((cnt1*(cnt2-1))/2)


print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
N, *A = [float(_) for _ in open(0).read().split()]
N = int(N)
c = [[0, 0] for _ in range(N)]
for i, a in enumerate(A):
    a = int(a * 10**9)
    while True:
        if a % 2:
            break
        c[i][0] += 1
        a //= 2
    while True:
        if a % 5:
            break
        c[i][1] += 1
        a //= 5
c.sort()

#cum[i][j]:c[x][1]>=i (j<=x)となるようなxの個数
cum = [[0] * (N + 1) for _ in range(19)]
for i in range(19):
    for j in range(N - 1, -1, -1):
        cum[i][j] = cum[i][j + 1]
        if c[j][1] >= i:
            cum[i][j] += 1
ans = 0
c99 = [0, -1]
for i, c2c5 in enumerate(c):
    c2, c5 = c2c5
    if c2 == c5 == 9:
        c99[0] += 1
        c99[1] = cum[9][i + 1]
        continue
    elif c2 > 9 or (c2 == 9 and c5 > 9):
        i2 = i + 1
    else:
        i2 = bisect.bisect_left(c, [18 - c2, -1])
    ans += cum[18 - c5][i2]
ans += c99[0] * (c99[0] - 1) // 2
ans += c99[0] * c99[1]
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
N, *A = [float(_) for _ in open(0).read().split()]
N = int(N)
c = [[0, 0] for _ in range(N)]
for i, a in enumerate(A):
    a = int(a * 10**9)
    while True:
        if a % 2:
            break
        c[i][0] += 1
        a //= 2
    while True:
        if a % 5:
            break
        c[i][1] += 1
        a //= 5
c.sort()

#cum[i][j]:c[x][1]>=i (j<=x)となるようなxの個数
cum = [[0] * (N + 1) for _ in range(19)]
for i in range(19):
    for j in range(N - 1, -1, -1):
        cum[i][j] = cum[i][j + 1]
        if c[j][1] >= i:
            cum[i][j] += 1
ans = 0
c99 = [0, -1]
for i, c2c5 in enumerate(c):
    c2, c5 = c2c5
    if c2 == c5 == 9:
        c99[0] += 1
        c99[1] = cum[9][i + 1]
        continue
    elif c2 > 9 or (c2 == 9 and c5 > 9):
        i2 = i + 1
    elif c2 == 9:
        i2 = bisect.bisect_left(c, [18 - c2, 18 - c5])
    else:
        i2 = bisect.bisect_left(c, [18 - c2, -1])
    ans += cum[18 - c5][i2]
ans += c99[0] * (c99[0] - 1) // 2
ans += c99[0] * c99[1]
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
N, *A = [float(_) for _ in open(0).read().split()]
N = int(N)
c = [[0, 0] for _ in range(N)]
for i, a in enumerate(A):
    a = int(a * 10**9)
    while True:
        if a % 2:
            break
        c[i][0] += 1
        a //= 2
    while True:
        if a % 5:
            break
        c[i][1] += 1
        a //= 5
c.sort()

#cum[i][j]:c[x][1]>=i (j<=x)となるようなxの個数
cum = [[0] * (N + 1) for _ in range(19)]
for i in range(19):
    for j in range(N - 1, -1, -1):
        cum[i][j] = cum[i][j + 1]
        if c[j][1] >= i:
            cum[i][j] += 1
ans = 0
c99 = [0, -1]
for i, c2c5 in enumerate(c):
    c2, c5 = c2c5
    if c2 == c5 == 9:
        c99[0] += 1
        c99[1] = cum[9][i + 1]
        continue
    elif c2 > 9 or (c2 == 9 and c5 > 9):
        i2 = i + 1
    else:
        i2 = bisect.bisect_left(c, [18 - c2, 18 - c5])
    ans += cum[18 - c5][i2]
ans += c99[0] * (c99[0] - 1) // 2
ans += c99[0] * c99[1]
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[]
PRECISION_DIGITS=9
cnt={}


for n in range(N):
	tmpA = float(input())
	tmpA = tmpA*(10**PRECISION_DIGITS)
	#print(tmpA)

	two = 0
	five = 0
	while (tmpA % 2) == 0:
		two += 1
		tmpA /= 2
	while (tmpA % 5) == 0:
		five += 1
		tmpA /= 5

	if (two,five) in cnt:
		cnt[(two,five)]+=1
	else:
		cnt[(two,five)]=1

# print(cnt)
ans = 0
for t1, cnt1 in cnt.items():
	for t2, cnt2 in cnt.items():
		# 2**a(a>=0) and 5**b(b>=0) => integer
		if 18 <= t1[0]+t2[0] and 18 <= t1[1]+t2[1]:
			if t1 < t2:
				ans += int(cnt1*cnt2)
			elif t1 == t2:
				# same entry
				# Total number of combinations choose 2 items
				# nC2 = n*(n-1)/2
				ans += int(cnt1*(cnt2-1)/2)


print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
N, *A = [float(_) for _ in open(0).read().split()]
N = int(N)
c = [[0, 0] for _ in range(N)]
for i, a in enumerate(A):
    a = int(a * 10**9)
    while True:
        if a % 2:
            break
        c[i][0] += 1
        a //= 2
    while True:
        if a % 5:
            break
        c[i][1] += 1
        a //= 5
c.sort()

#cum[i][j]:c[x][1]>=i (j<=x)となるようなxの個数
cum = [[0] * (N + 1) for _ in range(19)]
for i in range(19):
    for j in range(N - 1, -1, -1):
        cum[i][j] = cum[i][j + 1]
        if c[j][1] >= i:
            cum[i][j] += 1
ans = 0
c99 = [0, -1]
for i, c2c5 in enumerate(c):
    c2, c5 = c2c5
    if c2 == c5 == 9:
        c99[0] += 1
        c99[1] = cum[9][i + 1]
        continue
    elif c2 > 9 or c2 == 9 and c5 > 9:
        i2 = i + 1
    else:
        i2 = bisect.bisect_left(c, [18 - c2, 18 - c5])
    ans += cum[18 - c5][i2]
ans += c99[0] * (c99[0] - 1) // 2
ans += c99[0] * c99[1]
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
N, *A = [float(_) for _ in open(0).read().split()]
N = int(N)
c = [[0, 0] for _ in range(N)]
for i, a in enumerate(A):
    a = int(a * 10**9)
    while True:
        if a % 2:
            break
        c[i][0] += 1
        a //= 2
    while True:
        if a % 5:
            break
        c[i][1] += 1
        a //= 5
c.sort()

#cum[i][j]:c[x][1]>=i (j<=x)となるようなxの個数
cum = [[0] * (N + 1) for _ in range(19)]
for i in range(19):
    for j in range(N - 1, -1, -1):
        cum[i][j] = cum[i][j + 1]
        if c[j][1] >= i:
            cum[i][j] += 1
ans = 0
c99 = [0, 0]
for i, c2c5 in enumerate(c):
    c2, c5 = c2c5
    if c2 > 9 or c2 == 9 and c5 > 9:
        ans += cum[18 - c5][i + 1]
    elif c2 == c5 == 9:
        c99[0] += 1
        c99[1] = cum[9][i + 1]
        continue
    else:
        i2 = bisect.bisect_left(c, [18 - c2, 18 - c5])
        ans += cum[18 - c5][i2]
ans += c99[0] * (c99[0] - 1) // 2
ans += c99[0] * c99[1]
print(ans)

Submission status: Wrong Answer

Solution code:
#AGC047-A Integer Product
"""
小数または整数が与えられるので、その積が整数となるペアの個数を求めよ。

まず入力に10**9をかけることで、
問題を「その積が10**18の倍数となるペアの個数を求めよ」
とする。
その場合、とりあえず10**18を素因数分解すると2**18と5**18なので、
片方が因数分解済みであるとした時に、
dp[i][j] : 2**iかつ5**jの個数
として、もう片方を2**aかつ5**bであると考えた時に、
2**(i+a)>=18かつ5**(j+b)>=18となるならば、それは条件を満たす
と考えられる。

よってこの個数を数えることで問題が解けた。
"""
import sys
from decimal import Decimal
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n = int(readline())
lst1  = [] 
for i in range(n):
    lst1.append(int(Decimal(input())*(10**9)))

dp = [[0]*20 for _ in range(50)]

ans = 0

for i in range(n):
    res = lst1[i]
    t,f = 0,0
    while True:
        if res%2==0:
            res //= 2
            t += 1
        else:
            break
    while True:
        if res%5==0:
            res //= 5
            f += 1
        else:
            break
    #i+t>=18かつj+f>=18であるような場所からカウント
    for i in range(18-t,50):
        for j in range(18-f,20):
            ans += dp[i][j]
            if dp[i][j]:
                print(i,j)
    dp[t][f] += 1

print(ans)

Submission status: Wrong Answer

Solution code:
#AGC047-A Integer Product
"""
小数または整数が与えられるので、その積が整数となるペアの個数を求めよ。

まず入力に10**9をかけることで、
問題を「その積が10**18の倍数となるペアの個数を求めよ」
とする。
その場合、とりあえず10**18を素因数分解すると2**18と5**18なので、
片方が因数分解済みであるとした時に、
dp[i][j] : 2**iかつ5**jの個数
として、もう片方を2**aかつ5**bであると考えた時に、
2**(i+a)>=18かつ5**(j+b)>=18となるならば、それは条件を満たす
と考えられる。

よってこの個数を数えることで問題が解けた。
"""
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n = int(readline())
lst1  = [] 
for i in range(n):
    lst1.append(int(float(readline())*(10**9)))

dp = [[0]*20 for _ in range(50)]

ans = 0

for i in range(n):
    res = lst1[i]
    t,f = 0,0
    while True:
        if res%2==0:
            res //= 2
            t += 1
        else:
            break
    while True:
        if res%5==0:
            res //= 5
            f += 1
        else:
            break
    #i+t>=18かつj+f>=18であるような場所からカウント
    for i in range(18-t,50):
        for j in range(18-f,20):
            ans += dp[i][j]
    dp[t][f] += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[]
PRECISION_DIGITS=9
cnt={}


for n in range(N):
	tmpA = float(input())
	tmpA = tmpA*10**PRECISION_DIGITS
	#print(tmpA)

	five = 0
	two = 0
	while (tmpA % 2) == 0:
		two += 1
		tmpA //= 2
	while (tmpA % 5) == 0:
		five += 1
		tmpA //= 5

	# (10**9) -> (two,five)=(9,9)
	two -= PRECISION_DIGITS
	five -= PRECISION_DIGITS

	if (two,five) in cnt:
		cnt[(two,five)]+=1
	else:
		cnt[(two,five)]=1

# print(cnt)
ans = 0
for t1, cnt1 in cnt.items():
	for t2, cnt2 in cnt.items():
		# 2**a(a>=0) and 5**b(b>=0) => integer
		if 0 <= t1[0]+t2[0] and 0 <= t1[1]+t2[1]:
			if t1 < t2:
				ans += int(cnt1*cnt2)
			elif t1 == t2:
				# same entry
				# Total number of combinations choose 2 items
				# nC2 = n*(n-1)/2
				ans += int((cnt1*(cnt2-1))/2)


print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[]
PRECISION_DIGITS=9
cnt={}


for n in range(N):
	tmpA = float(input())
	tmpA = tmpA*10**PRECISION_DIGITS
	#print(tmpA)

	five = 0
	two = 0
	while (tmpA % 2) == 0:
		two += 1
		tmpA /= 2
	while (tmpA % 5) == 0:
		five += 1
		tmpA /= 5

	# (10**9) -> (two,five)=(9,9)
	two -= PRECISION_DIGITS
	five -= PRECISION_DIGITS

	if (two,five) in cnt:
		cnt[(two,five)]+=1
	else:
		cnt[(two,five)]=1

# print(cnt)
ans = 0
for t1, cnt1 in cnt.items():
	for t2, cnt2 in cnt.items():
		# 2**a(a>=0) and 5**b(b>=0) => integer
		if 0 <= t1[0]+t2[0] and 0 <= t1[1]+t2[1]:
			if t1 < t2:
				ans += cnt1*cnt2
			elif t1 == t2:
				# same entry
				# Total number of combinations choose 2 items
				# nC2 = n*(n-1)/2
				ans += int((cnt1*(cnt2-1))/2)


print(int(ans))