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:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline
readline = input

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap

from fractions import Fraction

@mt
def slv(N, A):
    d = defaultdict(Counter)
    nd = Counter()
    for a in A:
        t = a.split('.')
        b = 0
        if len(t) == 1:
            b = int(t[0]) * 10**9
        else:
            b = int(t[0]) * 10**9 + int(t[1]) * 10**(9- len(t[1]))
        e = str(b)
        for i in range(100):
            if e[-(i+1)] != '0':
                break
        d[i][b] += 1
        nd[i] += 1

    ans = 0
    rk = sorted(d.keys(), reverse=True)
    for k, kk in combinations(rk, r=2):
        nk = nd[k]
        nkk = nd[kk]
        if k + kk >= 18:
            ans += nk * nkk
        elif k + kk >= 10:
            for av, an in d[k].items():
                for bv, bn in d[kk].items():
                    if (av * bv) % 10**18 == 0:
                        ans += an * bn
    for k in rk:
        nk = nd[k]
        if 2*k >= 18:
            ans += nk * (nk-1) // 2
        elif 2*k >= 10:
            for av, bv in combinations_with_replacement(d[k], r=2):
                an = d[k][av]
                bn = d[k][bv]
                if (av * bv) % 10**18 == 0:
                    if av == bv:
                        ans += an * (an-1) // 2
                    else:
                        ans += an * bn
    return ans


def ref(N, A):
    B = []
    for a in A:
        t = a.split('.')
        b = 0
        if len(t) == 1:
            b = int(t[0]) * 10**9
        else:
            b = int(t[0]) * 10**9 + int(t[1]) * 10**(9 - len(t[1]))
        B.append(b)

    ans = 0
    for a, b in combinations(B, r=2):
        if (a * b ) % 10**18 == 0:
            print(a, b)
            ans += 1
    return ans

def main():
    N = read_int()
    A = [input() for _ in range(N)]
    print(slv(N, A))
    # print(ref(N, A))

    # N = 1000
    # for _ in range(1000):
    #     A = []
    #     # A = ['7.8', '7.36', '1.79', '7.83', '1.89', '3.16', '4.40', '7.42', '5.2', '4.98', '1.15', '5.66', '5.49', '6.51', '3.50', '1.96', '5.76', '1.32', '10.59', '4.58', '2.52', '3.32', '10.69', '7.97', '2.74', '7.17', '1.76', '5.33', '4.77', '10.20', '2.36', '5.60', '3.0', '5.44', '9.21', '9.52', '5.29', '6.28', '3.46', '10.58', '7.79', '1.50', '6.56', '7.56', '6.13', '10.9', '4.94', '4.49', '9.24', '4.1', '4.70', '5.56', '5.45', '2.91', '7.54', '3.79', '7.71', '5.13', '2.19', '1.76', '8.65', '8.14', '5.7', '10.50', '9.66', '4.21', '8.14', '7.59', '1.35', '8.79', '4.99', '1.63', '7.72', '7.41', '1.18', '1.13', '10.63', '3.68', '4.20', '9.71', '1.89', '7.8', '8.56', '10.30', '1.13', '5.90', '7.79', '4.18', '7.14', '8.80', '4.93', '10.60', '2.58', '3.75', '10.74', '6.24', '2.77', '5.88', '1.4', '6.4']
    #     for _ in range(N):
    #         b = str(random.randint(1, 1000)) + '.' + str(random.randint(0, 10**7))
    #         A.append(b)

    #     a = slv(N, A)
    #     b = ref(N, A)
    #     print(a, b)
    #     if a != b:
    #         print(a, b)
    #         print(A)
    #         break



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def prime(n):
    ans=[0,0]
    while int(n)!=n:
        if int(str(n)[-1])==5:
            ans[0]-=1
            n*=2
        elif int(str(n)[-1])%2==0:
            ans[1]-=1
            n*=5
        else:
            ans[0]-=1
            ans[1]-=1
            n*=10

    while n>0:
        if n%2==0:
            ans[0]+=1
            n//=2
        elif n%5==0:
            ans[1]+=1
            n//=5
        else:
            break
    return ans

n=int(input())
a=[float(input()) for _ in range(n)]
b=[[0,0] for _ in range(n)]
ans=0
for i in range(n):
    b[i][0]=prime(a[i])[0]
    b[i][1]=prime(a[i])[1]
c=[s for s in b if (2**max([0,-s[0]]))*(5**max([0,-s[1]]))<10**4]

d=[[0 for k in range(-13,14)] for l in range(-5,6)]

for i in range(len(c)):
    for k in range(-13,14):
        for l in range(-5,6):
            if c[i][0]>=k and c[i][1]>=l:
                d[l+5][k+13]+=1

for i in range(len(c)):
    ans+=d[-c[i][1]+5][-c[i][0]+13]
    if c[i][0]>=0 and c[i][1]>=0:
        ans-=1
print(ans//2)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
from decimal import Decimal

N, *A = map(Decimal, open(0).read().split())
N = int(N)
A.sort()

c = {}
intc = 0
ints = []
decs = []
for d in A:
    if d in c:
        c[d] += 1
        if d == int(d):
            intc += 1
    else:
        c[d] = 1
        if d == int(d):
            intc += 1
            ints.append(d)
        else:
            decs.append(d)

p = []
for i in range(len(decs)):
    a = decs[i]
    t = 10
    while True:
        a *= 10
        if a == int(a):
            p.append(t / 10)
            break
        t *= 10

result = intc * (intc - 1) // 2
for i in range(len(decs)):
    a = decs[i]
    t = max(bisect_left(decs, p[i]), i + 1)
    for j in range(t, len(decs)):
        b = decs[j]
        t = a * b
        if t == int(t):
            result += c[a] * c[b]

    t = bisect_left(ints, p[i])
    for j in range(t, len(ints)):
        b = ints[j]
        t = a * b
        if t == int(t):
            result += c[a] * c[b]

print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
X = [input() for i in range(N)]
k = 0
j = 1 
total = 0
while j<=N-1:
    while k<j:
        A = float(X[k])
        B = float(X[j])
        C = A*B
        while C >= 1:
            C = C-1
        if C == 0:
            total += 1
        else:
            total += 0
        k += 1
    j += 1
    k = 0
print(total)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
 
# 浮動小数点の入力
num_list = []
for i in range(a):
  num_list.append(float(input()))
 
count = 0
for i, v_i in enumerate(num_list):
  for j, v_j in enumerate(num_list):
    if i < j:
      b = v_i*v_j 
      if b.is_integer():
        count += 1
 
# 出力
print("{}".format(int(count)))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [float(input()) for i in range(N)]
#A = [len(input()) for i in range(N)]
count = 0
B = []
C = []

for i in range(N):
    if A[i] % 1 == 0:
        B.append(A[i])
    elif A[i] % 0.00001 == 0:
        C.append(A[i])

for i in range(len(B)):
    count += i

for i in B:
    for j in C:
        if ((i * j) % 1 == 0):
            count += 1

for i in range(len(C)):
    for j in range(i+1, len(C)):
        if ((C[i] * (10 ** 4)) * (C[j] * (10 ** 4))) % (1 * (10 ** 4) ** 2) == 0:
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline
readline = input

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap

from fractions import Fraction

@mt
def slv(N, A):
    d = defaultdict(Counter)
    nd = Counter()
    for a in A:
        t = a.split('.')
        b = 0
        if len(t) == 1:
            b = int(t[0]) * 10**9
        else:
            b = int(t[0]) * 10**9 + int(t[1]) * 10**(9- len(t[1]))
        e = str(b)
        for i in range(100):
            if e[-(i+1)] != '0':
                break
        d[i][b] += 1
        nd[i] += 1

    ans = 0
    rk = sorted(d.keys(), reverse=True)
    for k, kk in combinations(rk, r=2):
        nk = nd[k]
        nkk = nd[kk]
        if k + kk >= 18:
            ans += nk * nkk
        elif k + kk >= 13:
            for av, an in d[k].items():
                for bv, bn in d[kk].items():
                    if (av * bv) % 10**18 == 0:
                        ans += an * bn
    for k in rk:
        nk = nd[k]
        if 2*k >= 18:
            ans += nk * (nk-1) // 2
        elif 2*k >= 13:
            for av, bv in combinations_with_replacement(d[k], r=2):
                an = d[k][av]
                bn = d[k][bv]
                if (av * bv) % 10**18 == 0:
                    if av == bv:
                        ans += an * (an-1) // 2
                    else:
                        ans += an * bn
    return ans


def ref(N, A):
    B = []
    for a in A:
        t = a.split('.')
        b = 0
        if len(t) == 1:
            b = int(t[0]) * 10**9
        else:
            b = int(t[0]) * 10**9 + int(t[1]) * 10**(9 - len(t[1]))
        B.append(b)

    ans = 0
    for a, b in combinations(B, r=2):
        if (a * b ) % 10**18 == 0:
            print(a, b)
            ans += 1
    return ans

def main():
    N = read_int()
    A = [input() for _ in range(N)]
    print(slv(N, A))
    # print(ref(N, A))

    # N = 1000
    # for _ in range(1000):
    #     A = []
    #     # A = ['7.8', '7.36', '1.79', '7.83', '1.89', '3.16', '4.40', '7.42', '5.2', '4.98', '1.15', '5.66', '5.49', '6.51', '3.50', '1.96', '5.76', '1.32', '10.59', '4.58', '2.52', '3.32', '10.69', '7.97', '2.74', '7.17', '1.76', '5.33', '4.77', '10.20', '2.36', '5.60', '3.0', '5.44', '9.21', '9.52', '5.29', '6.28', '3.46', '10.58', '7.79', '1.50', '6.56', '7.56', '6.13', '10.9', '4.94', '4.49', '9.24', '4.1', '4.70', '5.56', '5.45', '2.91', '7.54', '3.79', '7.71', '5.13', '2.19', '1.76', '8.65', '8.14', '5.7', '10.50', '9.66', '4.21', '8.14', '7.59', '1.35', '8.79', '4.99', '1.63', '7.72', '7.41', '1.18', '1.13', '10.63', '3.68', '4.20', '9.71', '1.89', '7.8', '8.56', '10.30', '1.13', '5.90', '7.79', '4.18', '7.14', '8.80', '4.93', '10.60', '2.58', '3.75', '10.74', '6.24', '2.77', '5.88', '1.4', '6.4']
    #     for _ in range(N):
    #         b = str(random.randint(1, 1000)) + '.' + str(random.randint(0, 10**7))
    #         A.append(b)

    #     a = slv(N, A)
    #     b = ref(N, A)
    #     print(a, b)
    #     if a != b:
    #         print(a, b)
    #         print(A)
    #         break



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import bisect
from heapq import heappush, heappop
n = int(input())
a = []
for i in range(n):
    temp = float(input()) * (10**4)
    if temp%1 == 0:
        # print(temp)
        a.append(int(temp))
b = []
d = {0:0,1:0,2:0,3:0,4:0,5:0}
p = [[]for i in range(9)]
for i in a:
    cnt2 = 0
    cnt5 = 0
    while i%2 == 0:
        i //= 2
        cnt2 += 1
    while i%5 == 0:
        i //= 5
        cnt5 += 1
    p[min(8,cnt2)].append(-cnt5)
    # d[min(5,cnt5)] += 1
    # b.append([cnt2,cnt5])
# print(b)
# print(d)
ans = 0
for i in range(9):
    p[i] = sorted(p[i])
# print(p)
for i in range(9):
    while p[i]:
        t = p[i].pop()
        # print(t)
        # for j in p[i]:
        for k in range(max(0,8-i),9):
            # print(k,p[k],bisect.bisect_right(p[k],-8-t))
            ans += bisect.bisect_right(p[k],-8-t)
print(ans)
# for i in range(len(a)-1):
#     for j in range(i+1,len(a)):
#         if a[i] > 0 and a[j] > 0 and a[i]*a[j] %(10**8) == 0:
#             ans += 1
#             # print(a[i],a[j])
# print(ans)
# print(a)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n=int(input())
alist=[0]*n
cnt=0
for i in range(n):
  a=float(input())
  alist[i]=a
for i in range(n-1):
   for k in range(i+1,n):
      num=alist[i]*alist[k]
      if num.is_integer():
        cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
from scipy.special import comb

n = int(input())
count = 0
a = []
b = []
for i in range(n):
  x = float(input())
  if x.is_integer():
    count = count + 1
    b.append(x)
  else:
    a.append(x)
#  整数×整数
sum = comb(count, 2, exact= True)

#  小数×小数
for i in range(len(a)):
  x = a[i]
  for j in range(len(b)):
    if (x * b[j]).is_integer():
      sum = sum + 1

# 小数×商数
for i in range(len(a)):
  if str(a[i])[-1] == 1:
    continue
  elif str(a[i])[-1] == 3:
    continue
  elif str(a[i])[-1] == 7:
    continue
  elif str(a[i])[-1] == 9:
    continue
  else:
    for j in range(i, len(a)-1):
      if (a[i]* a[j]).is_integer():
          sum = sum + 1
print(sum)

Submission status: Wrong Answer

Solution code:


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    from collections import defaultdict
    dd = defaultdict(int)
    dd2 = defaultdict(int)
    S=0#整数の個数

    
    for _ in range(N):
        c=input()
        if float(c)==0:
            S+=1
            dd2[10,10]+=1
        else:
            if "." in c:
                c2=float(c)
                c=int(c2*(10**10))
                i=0
                j=0
                while c%2==0:
                    c=c//2
                    i+=1
                while c%5==0:
                    c=c//5
                    j+=1
                i-=10
                j-=10
                i=min(i,10)
                j=min(j,10)
                # print(c2,i,j)
                if min(i,j)>=0:#元が実質整数なら
                    dd2[(i,j)]+=1
                    S+=1
                else:
                    dd[(i,j)]+=1

            else:
                c=int(c)
                i=0
                j=0
                while c%2==0:
                    c=c//2
                    i+=1
                while c%5==0:
                    c=c//5
                    j+=1
                i=min(i,10)
                j=min(j,10)
                dd2[(i,j)]+=1
                S+=1
            
    ans=(S*(S-1))#あとで2でわる
    
    #dd同士の重複に注意
    
    # for k,v in dd2.items():
    #     print(k,v)
    
    K=[]
    V=[]
    for k,v in dd.items():
        K.append(k)
        V.append(v)
        
    
    for iiii in range(len(K)):
        k=K[iiii]
        v=V[iiii]
        
        # print(k,v)
    
        ii,jj=k
        for i in range(-10,11):
            for j in range(-10,11):
                if ii+i>=0 and jj+j>=0:
                    ans+=dd2[(i,j)]*v*2
                    ans+=dd[(i,j)]*v#自身との重複はあり得ない
                    
                    
                    
    print(ans//2)
            
    

            
                    
                       

 
               

main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[float(input()) for i in range(n)]
cou=0
for i in range(n):
  for j in range(i+1,n):
      if a[i]==int(a[i]) and a[j]==int(a[j]):
        
        cou+=1
      elif a[i]==int(a[i]):
        aj=a[j]-int(a[j])
        b=aj*a[i]
        c=b-int(b)
        if c==0:
          cou+=1
      elif a[j]==int(a[j]):
        ai=a[i]-int(a[i])
        b=ai*a[j]
        c=b-int(b)
        if c==0:
          cou+=1  

      else:

        b=a[i]*a[j]
        c=b-int(b)
        if c==0:
          
          cou+=1
print(cou)

Submission status: Wrong Answer

Solution code:
N = input()
N = int(N)
A = list()
i = 0
j = 1
s = 0
for i in range (N):
    a = input()
    a = float(a) * 10000000000
    A.append(a)
for i in range (N - 1):
    I = i
    for i in range (j):
        v = A[i] * A[j]
        if v / 100000000000000000000 == v//100000000000000000000:
            s = s + 1
        i = i + 1
    j = j + 1
    i = 0
print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [[0 for _ in range(100)] for _ in range(100)]
s = [[0 for _ in range(100)] for _ in range(100)]
x = [[0 for _ in range(2)] for _ in range(N)]
for i in range(N):
  x[i][0] = 50
  x[i][1] = 50
  S = input()
  A = float(S)
  if "." in S:
    ten = len(S) - S.index(".") - 1
    for j in range(len(S)-1):
      if S[len(S)-1-j] == "0":
        ten -= 1
      else:
        break
    x[i][0] += ten
    x[i][1] += ten
    A *= 10 ** ten
  while A % 5 == 0:
    A /= 5
    x[i][0] -= 1
  while A % 2 == 0:
    A /= 2
    x[i][1] -= 1
  a[x[i][0]][x[i][1]] += 1
for i in range(99):
  for j in range(99):
    s[i+1][j+1] = s[i][j+1] + s[i+1][j] - s[i][j] + a[i][j]
ans = 0
for i in range(N):
  if x[i][0] <= 50 and x[i][1] <= 50:
    ans -= 1
  ans += s[100-x[i][0]+1][100-x[i][1]+1]
print(ans//2)

Submission status: Wrong Answer

Solution code:
n=int(input())
a = [input().split() for l in range(n)]

t=0
p=0
q=0

for i in range(0,n):
    if float(float(a[i][0])*1000).is_integer() == False:
        p=p+1

for i in range(0,n-p):
    if float(float(a[i][0])*1000).is_integer() == False:
        a.pop(i-q)
        q=q+1

for i in range(0,len(a)-1):
    for j in range (i+1,len(a)):
        if float(a[i][0]).is_integer() == True and float(a[j][0]).is_integer() == True:
            t=t+1
        elif float(float(a[i][0])*float(a[j][0])).is_integer() == True:
            t=t+1
print(t)

Submission status: Wrong Answer

Solution code:
epsilon = 0.0000000001

def solve():
    N = int(input())
    nums = [float(input()) for _ in range(N)]
    ans = 0
    for i, num in enumerate(nums):
        for j in range(i + 1, N):
            if abs(int(num * nums[j]) - (num * nums[j])) < epsilon:
                ans += 1
    return ans


if __name__ == '__main__':
    print(solve())

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd
from operator import mul
from functools import reduce
from operator import mul
from pprint import pprint



sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.readline())
def FI(): return float(sys.stdin.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
A = []
c = 0
for i in range(n):
    r = FI()
    A += [r]
    if r % 1 == 0:
        c += 1

D = defaultdict(lambda:defaultdict(int))
for j in range(n):
    cnt1 = 0
    cnt2 = 0
    while A[j] % 1:
        A[j] *= 10
        cnt1 -= 1
        cnt2 -= 1
    while A[j] % 2 == 0:
        A[j] /= 2
        cnt1 += 1
    while A[j] % 5 == 0:
        A[j] /= 5
        cnt2 += 1
    D[cnt1][cnt2] += 1

ans = 0
for i in range(-35, 35):
    for j in range(-20, 20):
        for k in range(-35, 35):
            for l in range(-20, 20):
                if i + k >= 0 and j + l >= 0:
                    if i == k and j == l:
                        ans += D[i][j] * (D[k][l] - 1)
                        # cnt2 += D[i][j] * (D[k][l] - 1) // 2
                        #
                    else:
                        ans += D[i][j] * D[k][l]

print(ans // 2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [float(input()) for i in range(N)]
#A = [len(input()) for i in range(N)]
count = 0
B = []
C = []

for i in range(N):
    if A[i] % 1 == 0:
        B.append(A[i])
    elif A[i] % 1 != 0 and (A[i] * (10 ** 6)) % 1 == 0:
        C.append(A[i])

for i in range(len(B)):
    count += i

for i in B:
    for j in C:
        if ((i * j) % 1 == 0):
            count += 1

for i in range(len(C)):
    for j in range(i+1, len(C)):
        if ((C[i] * (10 ** 6)) * (C[j] * (10 ** 6))) % (1 * (10 ** 6) ** 2) == 0:
            count += 1

print(count)

Submission status: Wrong Answer

Solution code:
import sys
def input():
	return sys.stdin.readline()[:-1]

n = int(input())
cnt = [[0 for _ in range(20)] for _ in range(20)]
ans = 0
for _ in range(n):
	a = input()
	x, y = 0, 0
	if "." in a:
		i = len(a)-1
		while a[i] != ".":
			i -= 1
			x, y = x-1, y-1
		b = int(a[:i] + a[i+1:])
	else:
		b = int(a)
	#print(b)
	while b%2 == 0 and x < 10:
		x += 1
		b //= 2
	while b%5 == 0 and y < 10:
		y += 1
		b //= 5
	#print(x, y)
	x, y = x+9, y+9
	for i in range(18-x, 20):
		for j in range(18-y, 20):
			ans += cnt[i][j]
	cnt[x][y] += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [float(input()) for i in range(N)]
count=0
#print(A)
for i in range(len(A)):
    #print(a[i],'s')
    for j in range(i+1,len(A)):
        if i <j:
            #print(a[j],'ss')
            b=A[i]*A[j]
            #print(b)
            if b.is_integer() == True:
                #print(b,'bbb'+' '+str(A[i])+' '+str(A[j]))
                count+=1
print(count)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_right
N = int(input())
A = [float(input()) for _ in range(N)]
A.sort()
n,m = [],[]
ans = 0
for i in range(N):
  if A[i].is_integer():
    n.append(A[i])
  else:
    m.append(A[i])

for i in range(len(n)):
  ii = bisect_right(n,n[i])
  ans += (len(n)-ii)
  for j in range(len(m)):
    if (n[i]*m[j]).is_integer():
      ans += 1

for i in range(len(m)-1):
  for j in range(i+1,len(m)):
    if (m[i]*m[j]).is_integer() and m[i] < m[j]:
      ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline
readline = input

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap

from fractions import Fraction

@mt
def slv(N, A):
    d = defaultdict(Counter)
    nd = Counter()
    for a in A:
        t = a.split('.')
        b = 0
        if len(t) == 1:
            b = int(t[0]) * 10**9
        else:
            b = int(t[0]) * 10**9 + int(t[1]) * 10**(9- len(t[1]))
        e = str(b)
        for i in range(100):
            if e[-(i+1)] != '0':
                break
        d[i][b] += 1
        nd[i] += 1

    ans = 0
    rk = sorted(d.keys(), reverse=True)
    for k, kk in combinations(rk, r=2):
        nk = nd[k]
        nkk = nd[kk]
        if k + kk >= 18:
            ans += nk * nkk
        elif k + kk >= 14:
            for av, an in d[k].items():
                for bv, bn in d[kk].items():
                    if (av * bv) % 10**18 == 0:
                        ans += an * bn
    for k in rk:
        nk = nd[k]
        if 2*k >= 18:
            ans += nk * (nk-1) // 2
        elif 2*k >= 14:
            for av, bv in combinations_with_replacement(d[k], r=2):
                an = d[k][av]
                bn = d[k][bv]
                if (av * bv) % 10**18 == 0:
                    if av == bv:
                        ans += an * (an-1) // 2
                    else:
                        ans += an * bn
    return ans


def ref(N, A):
    B = []
    for a in A:
        t = a.split('.')
        b = 0
        if len(t) == 1:
            b = int(t[0]) * 10**9
        else:
            b = int(t[0]) * 10**9 + int(t[1]) * 10**(9 - len(t[1]))
        B.append(b)

    ans = 0
    for a, b in combinations(B, r=2):
        if (a * b ) % 10**18 == 0:
            print(a, b)
            ans += 1
    return ans

def main():
    N = read_int()
    A = [input() for _ in range(N)]
    print(slv(N, A))
    # print(ref(N, A))

    # N = 2 * 10**5
    # for _ in range(1000):
    #     A = []
    #     # A = ['7.8', '7.36', '1.79', '7.83', '1.89', '3.16', '4.40', '7.42', '5.2', '4.98', '1.15', '5.66', '5.49', '6.51', '3.50', '1.96', '5.76', '1.32', '10.59', '4.58', '2.52', '3.32', '10.69', '7.97', '2.74', '7.17', '1.76', '5.33', '4.77', '10.20', '2.36', '5.60', '3.0', '5.44', '9.21', '9.52', '5.29', '6.28', '3.46', '10.58', '7.79', '1.50', '6.56', '7.56', '6.13', '10.9', '4.94', '4.49', '9.24', '4.1', '4.70', '5.56', '5.45', '2.91', '7.54', '3.79', '7.71', '5.13', '2.19', '1.76', '8.65', '8.14', '5.7', '10.50', '9.66', '4.21', '8.14', '7.59', '1.35', '8.79', '4.99', '1.63', '7.72', '7.41', '1.18', '1.13', '10.63', '3.68', '4.20', '9.71', '1.89', '7.8', '8.56', '10.30', '1.13', '5.90', '7.79', '4.18', '7.14', '8.80', '4.93', '10.60', '2.58', '3.75', '10.74', '6.24', '2.77', '5.88', '1.4', '6.4']
    #     for _ in range(N):
    #         b = str(random.randint(1, 10)) + '.' + str(random.randint(0, 100))
    #         A.append(b)
    #     a = slv(N, A)
    #     # b = ref(N, A)
    #     # if a != b:
    #     #     print(a, b)
    #     #     print(A)
    #     #     break



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy

def process(num):
    cnt_2 = 0
    cnt_5 = 0

    while num%2 == 0:
        num = num//2
        cnt_2 += 1
    
    while num%5 == 0:
        num = num//5
        cnt_5 += 1
    
    # return cnt_2, cnt_5
    return min(9,cnt_2-9), min(9,cnt_5-9)


def solve(lst):  # fix inputs here
    console("----- solving ------")

    grid = [[0 for _ in range(20)] for _ in range(20)]

    console(lst)
    for num in lst:
        x,y = process(num)
        console(x,y)
        grid[x+10][y+10] += 1
    # return a string (i.e. not a list or matrix)

    # console(np.array(grid))

    res = 0

    for i in range(-9,9):
        for j in range(-9,9):
            smaller_cnt = 0
            # smaller_cnt -= grid[10+i][10+j]
            for x in range(10-i,20):
                for y in range(10-j,20):
                    smaller_cnt += grid[x][y]
            # val = grid[10+i][10+j] * smaller_cnt + (grid[10+i][10+j] * (grid[10+i][10+j] - 1))
            if i >= 0 and j >= 0:
                val = grid[10+i][10+j] * (smaller_cnt - grid[10+i][10+j]) 
                val += (grid[10+i][10+j] * (grid[10+i][10+j]-1))
            else:
                val = (grid[10+i][10+j]) * smaller_cnt
            if val != 0:
                console(i,j,smaller_cnt,val)
            # val = max(0,val)
            res += val
    console(res)
    return res//2


def console(*args):  # the judge will not read these print statement
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return

# fast read all
# sys.stdin.readlines()

# for case_num in [1]:
    # read line as a string
    # strr = input()

    # read line as an integer
nrows = int(input())
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    # lst = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
grid = []
for _ in range(nrows):
    grid.append(int(10**9 * float(input())))

res = solve(grid)  # please change
    
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
print(res)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# 整数の入力
a = int(input())
 
# 浮動小数点の入力
num_list = []
for i in range(a):
  num_list.append(float(input()))
 
count = 0
for i, v_i in enumerate(num_list):
  for j, v_j in enumerate(num_list):
    if i < j:
      if isinstance(v_i*v_j, int):
        count += 1
 
# 出力
print("{}".format(int(count)))

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
from math import floor


input = sys.stdin.readline
n = int(input())
a = np.array(float(input()))
cnt = 0
for _ in range(n - 1):
    x = float(input()) * 10000
    if x % 1 == 0:
        x /= 10000
    else:
        x = (floor(x) + 0.1) / 10000
    cnt += np.count_nonzero(a * x % 1 == 0)
    a = np.append(a, x)
print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

N = int(input())
A = np.array([],dtype=np.float128)
for _ in range(N):
    A = np.append(A, float(input()))
    
ans = 0

for i in range(N-1):
    for j in range(i+1, N):
        tmp = A[i] * A[j]
        if abs(tmp - round(tmp)) < 1e-14:
            ans += 1

print(ans)