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:
from sys import stdin
N = int(stdin.readline().rstrip())
# print(N)
ary=[]
for i in range(N):
  ary.append(float(stdin.readline().rstrip()))
  # stdin.readline().rstrip().split()
  # print(ary[i])
cnt = 0

# def get_divisible_count(num,divider):
#   result = 0
#   while True:    
#     if num%divider ==0:
#       result += 1
#       # num /= divider
#       num = int(num/divider)
#     else:
#       break
#   return result
def is_divisible(num,divider,times):
  result = 0
  while True:    
    if result ==times:
      return True
    elif num%divider ==0:
      result += 1
      # num /= divider
      num = int(num/divider)
    else:
      break
  return False

# print(get_divisible_count(27,3))
# print(is_divisible(27,3,4))

for i in range(N):

  for j in range(N-i-1):
    # print(i,j+i+1)
    # print(ary[i],ary[i+j+1],(((ary[i]%1)*(ary[j+i+1])%1)))
    num = (ary[i]*(10**9)) * (ary[j+i+1]*(10**9))
    if is_divisible(num,2,18):
      if is_divisible(num,5,18):
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
# a = list(sorted(map(lambda x: float(input(x)), range(n))))
a = [float(input()) for _ in range(n)]
c = 0
# print(a)
for i in range(n-1):
    for j in range(i+1, n):
        if a[i] == a[j]: continue
        p = a[i]*a[j]
        c += int(p)==p
print(c)

Submission status: Wrong Answer

Solution code:
def transform_n(num):
    num_splt = num.split(".")
    tens = 0
    if len(num_splt) > 1 and int(num_splt[1]) != 0:
        j = len(num_splt[1]) - 1
        while num_splt[1][j] == '0':
            j -= 1
        j += 1
        tens += j
        num_int = int(num_splt[0]) * 10 * tens + int(num_splt[1][:j])
    else:
        num_int = int(num_splt[0])
    return num_int, tens


def check_int(s1, s2):
    n1, t1 = transform_n(s1)
    n2, t2 = transform_n(s2)
    prod = n1 * n2
    t = t1 + t2
    prod = str(prod)
    for i in range(len(prod) - 1, -1, -1):
        if prod[i] != '0':
            break
        else:
            t -= 1
    if t <= 0:
        return True
    return False


def solve(arr):
    cnt = 0
    for i in range(len(arr)):
        for j in range(i + 1, len(arr)):
            # a1, a2 = arr[i], arr[j]
            # res = check_int(arr[i], arr[j])
            # print(f"a1: {a1}, a2: {a2}, prod: {float(a1) * float(a2)}, res: {res}")
            if check_int(arr[i], arr[j]):
                cnt += 1
    print(cnt)


n = int(input())
a = []
while n > 0:
    a.append(input())
    n -= 1
# print()
solve(a)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys 
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
cnt = Counter()

for i in range(N):
    cnt_2 = 0
    cnt_5 = 0
    a = float(readline())
    a = int(a * (10**9))
    while a % 2 == 0:
        a //= 2
        cnt_2 += 1
    while a % 5 == 0:
        a //= 5
        cnt_5 += 1
    cnt[(cnt_2-9,cnt_5-9)] += 1
    
ans = 0
for (x1,y1),c1 in cnt.items():
    for (x2,y2),c2 in cnt.items():
        if x1+x2 >= 0 and y1+y2 >= 0:
            if x1 == x2 and y1 == y2:
                ans += c1*(c1-1)
            else:
                ans += c1*c2

print(ans//2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys 
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
cnt = Counter()

for i in range(N):
    cnt_2 = 0
    cnt_5 = 0
    a = float(readline())
    a = int(a * (10**9))
    while a % 2 == 0:
        a //= 2
        cnt_2 += 1
    while a % 5 == 0:
        a //= 5
        cnt_5 += 1
    cnt[(cnt_2-9,cnt_5-9)] += 1
    
ans1 = 0
ans2 = 0
for (x1,y1),c1 in cnt.items():
    for (x2,y2),c2 in cnt.items():
        if x1+x2 >= 0 and y1+y2 >= 0:
            if x1 == x2 and y1 == y2:
                ans1 += c1*(c1-1)//2
            else:
                ans2 += c1*c2

ans2 //= 2
print(ans1 + ans2)

Submission status: Wrong Answer

Solution code:
import math

def IntegerProduct():

    num = int(input())
    
    value = []
    
    for i in range(num):
        value.append(float(input()))

    count = 0

    for i in range(num-1):
        for j in range(i+1, num):
            data = value[i]*value[j]
            
            f, k = math.modf(data)
                        
            if f == 0.0:
                count = count + 1
            
    print(count)

if __name__ == '__main__':
    IntegerProduct()

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[float(input()) for i in range(N)]
c=0
for i in range(N-1):
	for j in range(i+1,N):
		if int(A[i]*A[j])==(A[i]*A[j]):
			c+=1
print(c)

Submission status: Wrong Answer

Solution code:
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from itertools import product
def resolve():
    n = int(input())
    counter = [[0] * 100 for _ in range(100)] # 2^13 = 8192, 5^5 = 3125
    for _ in range(n):
        S = input()
        if '.' in S:
            a, b = S.split('.')
            two = five = -len(b)
            a = int(a + b)
        else:
            two = five = 0
            a = int(S)
        while a % 2 == 0:
            two += 1
            a //= 2
        while a % 5 == 0:
            five += 1
            a //= 5
        counter[two][five] += 1

    ans = 0
    for i0, j0 in product(range(-9, 14), range(-9, 6)):
        s = counter[i0][j0]
        for i1, j1 in product(range(-9, 14), range(-9, 6)):
            t = counter[i1][j1]
            if i0 + i1 < 0 or j0 + j1 < 0:
                continue
            if (i0, j0) == (i1, j1):
                ans += s * (s - 1) // 2
            elif (i0, j0) < (i1, j1):
                ans += s * t
    print(ans)
resolve()

Submission status: Wrong Answer

Solution code:
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from itertools import product
def resolve():
    n = int(input())
    counter = [[0] * 100 for _ in range(100)] # 2^13 = 8192, 5^5 = 3125
    for _ in range(n):
        S = input()
        if '.' in S:
            a, b = S.split('.')
            two = five = -len(b)
            a = int(a + b)
        else:
            two = five = 0
            a = int(S)
        while a % 2 == 0:
            two += 1
            a //= 2
        while a % 5 == 0:
            five += 1
            a //= 5
        counter[two][five] += 1

    ans = 0
    for i0, j0 in product(range(-12, 24), repeat = 2):
        s = counter[i0][j0]
        for i1, j1 in product(range(-12, 24), repeat = 2):
            t = counter[i1][j1]
            if i0 + i1 < 0 or j0 + j1 < 0:
                continue
            if (i0, j0) == (i1, j1):
                ans += s * (s - 1) // 2
            elif (i0, j0) < (i1, j1):
                ans += s * t
    print(ans)
resolve()

Submission status: Wrong Answer

Solution code:
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from itertools import product
def resolve():
    n = int(input())
    counter = [[0] * 100 for _ in range(100)] # 2^13 = 8192, 5^5 = 3125
    for _ in range(n):
        S = input()
        if '.' in S:
            a, b = S.split('.')
            two = five = -len(b)
            a = int(a + b)
        else:
            two = five = 0
            a = int(S)
        while a % 2 == 0:
            two += 1
            a //= 2
        while a % 5 == 0:
            five += 1
            a //= 5
        counter[two][five] += 1

    ans = 0
    for i0, j0 in product(range(-10, 20), repeat = 2):
        s = counter[i0][j0]
        for i1, j1 in product(range(-10, 20), repeat = 2):
            t = counter[i1][j1]
            if i0 + i1 < 0 or j0 + j1 < 0:
                continue
            if (i0, j0) == (i1, j1):
                ans += s * (s - 1) // 2
            elif (i0, j0) < (i1, j1):
                ans += s * t
    print(ans)
resolve()

Submission status: Wrong Answer

Solution code:
from numba import njit
import numpy as np
def main(n,a):
  mp=np.zeros((23,23),np.int32)
  o=11
  ary=[]
  for i in range(n):
    b=list(a[i].split('.'))
    b.append('0')
    x=int(b[0])
    y=int((b[1]+'0'*9)[:9])
    x=x*pow(10,9)+y
    # x10^9
    cnt5=-9
    xx=x
    while xx>1:
      if xx%5==0:
        cnt5+=1
        xx//=5
      else:
        break
    cnt2=-9
    xx=x
    while xx>1:
      if xx%2==0:
        cnt2+=1
        xx//=2
      else:
        break
    if 0<=cnt5+o<23 and 0<=cnt2+o<23:
      mp[cnt5+o,cnt2+o]+=1
      ary.append([cnt5+o,cnt2+o])

  ans=0
  for x,y in ary:
    if x>=o and y>=o:
      i=1
    else:
      i=0
    x-=o
    x*=-1
    x+=o
    y-=o
    y*=-1
    y+=o
    ans+=np.sum(mp[x:,y:])-i
  print(ans//2)
  #mp[o,o]+=10
  #print(mp)

n=int(input())
a=np.array([input() for _ in range(n)])
main(n,a)


"""
5
0.2
2
5
10
0.5

5
2.4
7.5
0.16
6.15
10


13
512
0.00097656
0.00024414
0.001953125
0.0016
0.00032
0.000064
0.0000128
0.00000256
0.000000512
615
999.999999999
0.000000001

"""

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [[0 for j in range(19)] for i in range(19)]
for i in range(N):
    A=input()
    tmp = int(float(A) * 10**9)
    # tmp = int(A.replace('.', ''))
    count2 = 0
    count5 = 0
    for _ in range(18):
        if tmp % 2 == 0:
            count2 += 1
            tmp /= 2
        else:
            break
    for _ in range(18):
        if tmp % 5 == 0:
            count5 += 1
            tmp /= 5
        else:
            break
    #  if A.find('.') > 0:
    #     count2 = count2 + 10 - len(A) + A.find('.')
    #     count5 = count5 + 10 - len(A) + A.find('.')
    # else:
    #     count2 += 9
    #     count5 += 9
    a[count2][count5] += 1
ans=0
for i in range(19):
    for i2 in range(19):
        for j in range(19):
            for j2 in range(19):
                if i + i2 >= 18 and j + j2 >= 18 and ( i < i2 or i == i2 and j <= j2) and a[i][j] >0 and a[i2][j2] > 0:
                    if i == i2 and j == j2:
                        ans += a[i][j] * (a[i][j]-1) // 2
                    else:
                        ans += a[i][j] * a[i2][j2]
print(ans)

Submission status: Wrong Answer

Solution code:
class cumsum2D:
    def __init__(self, data):
        self.N = len(data)
        self.M= len(data[0])
        self.cum = [[0] * (self.M + 1) for _ in range(self.N + 1)]
        for i in range(self.N):
            for j in range(self.M):
                self.cum[i + 1][j + 1] = self.cum[i][j + 1] + self.cum[i + 1][j] - self.cum[i][j] + data[i][j]

    def get(self,x1,y1,x2,y2):
        """
        長方形の領域 [x1,x2)*[y1,y2) の範囲内にインプットされた数字の和を取る
        """
        return self.cum[x2][y2] - self.cum[x1][y2] - self.cum[x2][y1] + self.cum[x1][y1]

def five(x):
    cnt1 = 0
    while x%5==0:
        cnt1+= 1
        x = x//5
    cnt2 = 0
    while x%2==0:
        cnt2+= 1
        x = x//2
    return (min(cnt1,18), min(cnt2,18))

def digit_lift(S, l):
    if '.' in S:
        a, b = S.split('.')
        n = int(a + b) * 10 ** (l - len(b))
    else:
        n = int(S) * 10 ** l
    return n

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

N = int(input())
Q = set()
for _ in range(N):
    A = digit_lift(input().rstrip(),9)
    x, y = five(A)
    data[x][y] += 1
    Q.add((x,y))

cum = cumsum2D(data)
res = 0
for x, y in Q:
    res += cum.get(18-x,18-y,-1,-1)*data[x][y] - (x>=9 and y>=9)
print(res//2)

Submission status: Wrong Answer

Solution code:
class cumsum2D:
    def __init__(self, data):
        self.N = len(data)
        self.M= len(data[0])
        self.cum = [[0] * (self.M + 1) for _ in range(self.N + 1)]
        for i in range(self.N):
            for j in range(self.M):
                self.cum[i + 1][j + 1] = self.cum[i][j + 1] + self.cum[i + 1][j] - self.cum[i][j] + data[i][j]

    def get(self,x1,y1,x2,y2):
        """
        長方形の領域 [x1,x2)*[y1,y2) の範囲内にインプットされた数字の和を取る
        """
        return self.cum[x2][y2] - self.cum[x1][y2] - self.cum[x2][y1] + self.cum[x1][y1]

def five(x):
    cnt1 = 0
    while x%5==0:
        cnt1+= 1
        x = x//5
    cnt2 = 0
    while x%2==0:
        cnt2+= 1
        x = x//2
    return (min(cnt1,18), min(cnt2,18))

def digit_lift(S, l):
    if '.' in S:
        a, b = S.split('.')
        n = int(a + b) * 10 ** (l - len(b))
    else:
        n = int(S) * 10 ** l
    return n

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

N = int(input())
Q = set()
for _ in range(N):
    A = digit_lift(input().rstrip(),9)
    x, y = five(A)
    data[x][y] += 1
    Q.add((x,y))

cum = cumsum2D(data)
res = 0
for x, y in Q:
    res += cum.get(18-x,18-y,-1,-1)*data[x][y]
print((res-2*data[9][9])//2)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [[0 for j in range(19)] for i in range(19)]
for i in range(N):
    A=input()
    tmp = int(float(A) * 10**9)
    # tmp = int(A.replace('.', ''))
    count2 = 0
    count5 = 0
    for _ in range(18):
        if tmp % 2 == 0:
            count2 += 1
            tmp /= 2
        else:
            break
    for _ in range(18):
        if tmp % 5 == 0:
            count5 += 1
            tmp /= 5
        else:
            break
    # if A.find('.') > 0:
    #     count2 += 10 - len(a) + A.find('.')
    #     count5 += 10 - len(a) + A.find('.')
    # else:
    #     count2 += 9
    #     count5 += 9
    a[count2][count5] += 1
ans=0
for i in range(19):
    for i2 in range(19):
        for j in range(19):
            for j2 in range(19):
                if i + i2 >= 18 and j + j2 >= 18 and ( i < i2 or i == i2 and j <= j2) and a[i][j] >0 and a[i2][j2] > 0:
                    if i == i2 and j == j2:
                        ans += a[i][j] * (a[i][j]-1) // 2
                    else:
                        ans += a[i][j] * a[i2][j2]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [[0 for j in range(19)] for i in range(19)]
for i in range(N):
    A=input()
    tmp = float(A) * 10**9
    # tmp = int(A.replace('.', ''))
    count2 = 0
    count5 = 0
    for _ in range(18):
        if tmp % 2 == 0:
            count2 += 1
            tmp /= 2
        else:
            break
    for _ in range(18):
        if tmp % 5 == 0:
            count5 += 1
            tmp /= 5
        else:
            break
    # if A.find('.') > 0:
    #     count2 += 10 - len(a) + A.find('.')
    #     count5 += 10 - len(a) + A.find('.')
    # else:
    #     count2 += 9
    #     count5 += 9
    a[count2][count5] += 1
ans=0
for i in range(19):
    for i2 in range(19):
        for j in range(19):
            for j2 in range(19):
                if i + i2 >= 18 and j + j2 >= 18 and ( i < i2 or i == i2 and j <= j2) and a[i][j] >0 and a[i2][j2] > 0:
                    if i == i2 and j == j2:
                        ans += a[i][j] * (a[i][j]-1) // 2
                    else:
                        ans += a[i][j] * a[i2][j2]
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())
MAX = 10 ** 9
d = defaultdict(int)
for i in range(N):
    a = float(input()) * MAX
    two = 0
    while a % 2 == 0:
        two += 1
        a //= 2
    five = 0
    while a % 5 == 0:
        five += 1
        a //= 5
    d[(two, five)] += 1

ans = 0
for p1 in d.keys():
    for p2 in d.keys():
        if (p1[0] + p2[0] >= 18) and (p1[1] + p2[1] >= 18):
            if p1 < p2:
                ans += d[p1] * d[p2]
            elif p1 == p2:
                ans += d[p1] * (d[p1] - 1) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
import copy
import math
import time
import statistics
import math
from decimal import Decimal
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_DOWN

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''



def main():
    start = time.time()

    n = get_int()
    #youso2 = []
    #youso5 = []
    youso = []
    aite = [[0] * 20 for i in range(20)]

    ans = 0
    for i in range(0,n):
        s = input()
        wk = Decimal(s)
        wk = wk - wk.quantize(Decimal('0'), rounding=ROUND_DOWN)
        seisu = Decimal.is_zero(wk)

        if seisu:
            if '.' in s:
                s_i, s_d = s.split('.')
                s = s_i

            count2 = 0
            wk = int(s)
            for ii in range(0, 9):
                if wk % 2 == 0:
                    count2 += 1
                    wk = wk // 2
                else:
                    break

            count5 = 0
            wk = int(s)
            for ii in range(0, 9):
                if wk % 5 == 0:
                    count5 += 1
                    wk = wk // 5
                else:
                    break

            #youso.append([count2, count5])

        else:
            s_i, s_d = s.split('.')

            while s_d[-1] == '0':
                s_d = s_d[:-1]

            count2 = 0
            wk = int(s_i + s_d)
            for ii in range(0, 9):
                if (wk * 2) % 10 == 0:
                    wk = wk * 2 / 10
                    count2 += 1
                else:
                    break

            count5 = 0
            wk = int(s_i + s_d)
            for ii in range(0,9):
                if (wk * 5) % 10 == 0:
                    wk = wk * 5 / 10
                    count5 += 1
                else:
                    break

            count2_wk = -len(s_d) + count5
            count5 = -len(s_d) + count2
            count2 = count2_wk
            #youso.append([-len(s_d) + count5, -len(s_d) + count2])

        youso.append([count2, count5])
        aite[10 - count2][10 - count5] += 1
        #for ii in range (10 - count2, 20):
        #    for iii in range(10 - count5, 20):
        #        aite[ii][iii] += 1


    #print(time.time() - start)

    aite2 = [[0] * 20 for i in range(20)]
    for i in range (0,20):
        for ii in range (0, 20):
            for iii in range(i, 20):
                for iiii in range(ii, 20):
                    aite2[iii][iiii] += aite[i][ii]

    #print(time.time() - start)
    #print(youso)

    #for i in range(len(aite2)):
    #    print(i, aite2[i])

    ans = 0
    for i in range(0,n):
        y1 = youso[i]
        if y1[0] >= 0 and y1[1] >= 0:
            ans += aite2[10 + y1[0]][10 + y1[1]] -1
        else:
            ans += aite2[10 + y1[0]][10 + y1[1]]

    ans = ans // 2

    print(ans)
    #print(time.time() - start)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())
MAX = 10 ** 9
A = [float(input()) * MAX for _ in range(N)]

d = defaultdict(int)
for a in A:
    two = 0
    while a % 2 == 0:
        two += 1
        a //= 2
    five = 0
    while a % 5 == 0:
        five += 1
        a //= 5
    d[(two, five)] += 1

ans = 0
for p1 in d.keys():
    for p2 in d.keys():
        if (p1[0] + p2[0] >= 18 and p1[1] + p2[1] >= 18):
            if p1 < p2:
                ans += d[p1] * d[p2]
            elif p1 == p2:
                ans += d[p1] * (d[p1] - 1) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
def divide(n, p):
    c = 0
    while n%p == 0 and c < 18:
        c += 1
        n //= p
    return c

n = int(input())
table = [[0]*19 for _ in range(19)]
for i in range(n):
    s = int(10**9*float(input()))
    c2, c5 = divide(s, 2), divide(s, 5)
    table[c2][c5] += 1

ans = 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 or j+l < 18:
                    continue;
                if i == k and j == l:
                    ans += table[i][j]*(table[k][l]-1)
                else:
                    ans += table[i][j]*table[k][l]

ans //= 2
print(ans)

Submission status: Wrong Answer

Solution code:
def divide(n, p):
    c = 0
    while n%p == 0 and c < 18:
        c += 1
        n //= p
    return c
    

n = int(input())
dp = [[0]*19 for _ in range(19)]
    
for i in range(n):
    s = float(input())
    s = int(1000000000*s)
    c1, c2 = divide(s, 2), divide(s, 5)
    dp[c1][c2] += 1
    
ans = 0
for i1 in range(19):
    for j1 in range(19):
        for i2 in range(19):
            for j2 in range(19):
                if i1+i2 >= 18 and j1+j2 >= 18:
                    if i1 == i2 and j1 == j2:
                        ans += dp[i1][j1]*(dp[i1][j1]-1)//2
                    elif i1 < i2:
                        ans += dp[i1][j1]*dp[i2][j2]
            
        
print(ans)

Submission status: Wrong Answer

Solution code:
def divide(n, p):
    c = 0
    while n%p == 0 and c < 18:
        c += 1
        n //= p
    return c
    

n = int(input())
dp = [[0]*19 for _ in range(19)]
    
for i in range(n):
    s = float(input())
    s = int(1000000000*s)
    c1, c2 = divide(s, 2), divide(s, 5)
    dp[c1][c2] += 1
    
ans = 0
for i1 in range(19):
    for j1 in range(19):
        for i2 in range(19):
            for j2 in range(19):
                if i1+i2 >= 18 and j1+j2 >= 18:
                    if i1 == i2 and j1 == j2:
                        ans += dp[i1][j1]*(dp[i1][j1]-1)//2
                    elif i1 < i2:
                        ans += dp[i1][j1]*dp[i2][j2]
            
        
print(ans//2)

Submission status: Wrong Answer

Solution code:
n = int(input())

a = [float(input()) * 10**9 for i in range(n)]

answer = 0

for i in range(n-1):
    for j in range(i+1,n):
        x = a[i] * a[j]
        if x % 10**18 == 0:
            answer += 1

print(answer)

Submission status: Wrong Answer

Solution code:
def divide(n, p):
    c = 0
    while n%p == 0 and c < 18:
        c += 1
        n //= p
    return c
    

n = int(input())
dp = [[0]*19 for _ in range(19)]
    
for i in range(n):
    s = float(input())
    s = int(1000000000*s)
    c1, c2 = divide(s, 2), divide(s, 5)
    dp[c1][c2] += 1
    
ans = 0
for i1 in range(19):
    for j1 in range(19):
        for i2 in range(19):
            for j2 in range(19):
                if i1+i2 >= 18 and j1+j2 >= 18:
                    if i1 == i2 and j1 == j2:
                        ans += dp[i1][j1]*(dp[i1][j1]-1)
                    else:
                        ans += dp[i1][j1]*dp[i2][j2]
            
        
print(ans//2)

Submission status: Wrong Answer

Solution code:
def divide(n, p):
    c = 0
    while n%p == 0 and c < 18:
        c += 1
        n //= p
    return c
    

n = int(input())
dp = [[0]*20 for _ in range(20)]
    
for i in range(n):
    s = float(input())
    s = int(1000000000*s)
    c1, c2 = divide(s, 2), divide(s, 5)
    dp[c1][c2] += 1
    
ans = 0
for i1 in range(20):
    for j1 in range(20):
        for i2 in range(20):
            for j2 in range(20):
                if i1+i2 >= 18 and j1+j2 >= 18:
                    if i1 == i2 and j1 == j2:
                        ans += dp[i1][j1]*(dp[i1][j1]-1)
                    else:
                        ans += dp[i1][j1]*dp[i2][j2]
            
        
print(ans//2)

Submission status: Wrong Answer

Solution code:
import copy
import math
import time
import statistics
import math
from decimal import Decimal
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_DOWN

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''



def main():
    start = time.time()

    n = get_int()
    #youso2 = []
    #youso5 = []
    youso = []
    aite = [[0] * 20 for i in range(20)]

    ans = 0
    for i in range(0,n):
        s = input()
        wk = Decimal(s)
        wk = wk - wk.quantize(Decimal('0'), rounding=ROUND_DOWN)
        seisu = Decimal.is_zero(wk)

        if seisu:
            if '.' in s:
                s_i, s_d = s.split('.')
                s = s_i

            count2 = 0
            wk = int(s)
            for ii in range(0, 9):
                if wk % 2 == 0:
                    count2 += 1
                    wk = wk // 2
                else:
                    break

            count5 = 0
            wk = int(s)
            for ii in range(0, 9):
                if wk % 5 == 0:
                    count5 += 1
                    wk = wk // 5
                else:
                    break

            #youso.append([count2, count5])

        else:
            s_i, s_d = s.split('.')

            while s_d[-1] == '0':
                s_d = s_d[:-1]

            count2 = 0
            wk = int(s_i + s_d)
            for ii in range(0, 9):
                if (wk * 2) % 10 == 0:
                    wk = wk * 2 / 10
                    count2 += 1
                else:
                    break

            count5 = 0
            wk = int(s_d)
            for ii in range(0,9):
                if (wk * 5) % 10 == 0:
                    wk = wk * 5 / 10
                    count5 += 1
                else:
                    break

            count2_wk = -len(s_d) + count5
            count5 = -len(s_d) + count2
            count2 = count2_wk
            #youso.append([-len(s_d) + count5, -len(s_d) + count2])

        youso.append([count2, count5])
        aite[10 - count2][10 - count5] += 1
        #for ii in range (10 - count2, 20):
        #    for iii in range(10 - count5, 20):
        #        aite[ii][iii] += 1


    #print(time.time() - start)

    aite2 = [[0] * 20 for i in range(20)]
    for i in range (0,20):
        for ii in range (0, 20):
            for iii in range(i, 20):
                for iiii in range(ii, 20):
                    aite2[iii][iiii] += aite[i][ii]

    #print(time.time() - start)
    #print(youso)

    #for i in range(len(aite2)):
    #    print(i, aite2[i])

    ans = 0
    for i in range(0,n):
        y1 = youso[i]
        if y1[0] >= 0 and y1[1] >= 0:
            ans += aite2[10 + y1[0]][10 + y1[1]] -1
        else:
            ans += aite2[10 + y1[0]][10 + y1[1]]

    ans = ans // 2

    print(ans)
    #print(time.time() - start)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
debug=False
import random
from collections import Counter
from collections import defaultdict
from itertools import combinations
def fact(n):
    k5 = 0
    while n%5==0:
        n//=5
        k5+=1
    k2=0
    while n%2==0:
        n//=2
        k2+=1
    return (k2, k5)

n=5*10**4 if debug else int(input())
a=[]
aa=[]
inp = [] if not debug else [str(random.random()*10**4) for _ in range(n)]
if not debug:
    for _ in range(n):
        inp.append(input())
    
for i in range(n):
    n=inp[i]
    aa.append(n)
    if "." in n:
        p,q=n.split(".")
        a.append((int(p+q),len(q)))
    else:
        p=int(n)
        q=0
        a.append((p,0))
    
G=[]
for idx,v in enumerate(a):
    r2, r5 = fact(v[0])
    #print(r2,r5,v[1])
    G.append((r2-v[1], r5-v[1]))

H=Counter(G)

L = [(i,j) for i in range(-15,15) for j in range(-15,15)]

c=0
#print(H)
for l,m in combinations(L,2):
    if l[0]+m[0]>=0 and l[1]+m[1]>=0:
        k = H[l]*H[m]
        if k>0:
            #print(l,m,k)
            c+=k
            
for i in range(0,15):
    k = H[(i,i)]*(H[(i,i)]-1)//2
    if k>0:
        #print(l,l,k)
        c+=k
print(c)

Submission status: Wrong Answer

Solution code:
debug=False
import random
from collections import Counter
from collections import defaultdict
from itertools import combinations
def fact(n):
    k5 = 0
    while n%5==0:
        n//=5
        k5+=1
    k2=0
    while n%2==0:
        n//=2
        k2+=1
    return (k2, k5)

n=5*10**4 if debug else int(input())
a=[]
aa=[]
inp = [] if not debug else [str(random.random()*10**4) for _ in range(n)]
if not debug:
    for _ in range(n):
        inp.append(input())
    
for i in range(n):
    n=inp[i]
    aa.append(n)
    if "." in n:
        p,q=n.split(".")
        a.append((int(p+q),len(q)))
    else:
        p=int(n)
        q=0
        a.append((p,0))
    
G=[]
for idx,v in enumerate(a):
    r2, r5 = fact(v[0])
    #print(r2,r5,v[1])
    G.append((r2-v[1], r5-v[1]))

H=Counter(G)

L = [(i,j) for i in range(-15,15) for j in range(-15,15)]

c=0
#print(H)
for l,m in combinations(L,2):
    if l[0]+m[0]>=0 and l[1]+m[1]>=0:
        k = H[l]*H[m]
        if k>0:
            #print(l,m,k)
            c+=k
            
for l in L:
    k = H[l]*(H[l]-1)//2
    if l[0]>=0 and l[1]>=0 and k>0:
        #print(l,l,k)
        c+=k
print(c)