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 itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re
import decimal
from decimal import Decimal

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def main_chk():
    decimal.getcontext().prec = 28
    A = []
    B = []
    ans = 0
    N = int(input())
    for i in range(N):
        chk = float(input())
        if chk.is_integer() == False:
            B.append(Decimal(chk))
        else:
            A.append(Decimal(chk))

    num_A = len(A)
    num_B = len(B)
    if num_A >= 2:
        ans = combinations_count(num_A,2)

    for i in range(num_A):
        for j in range(num_B):
            chk = float(Decimal(A[i])*Decimal(B[j]))
            if chk.is_integer() == True:
                ans = ans + 1

    for i in range(num_B-1):
        for j in range(i+1,num_B):
            chk = float(Decimal(B[i])*Decimal(B[j]))
            if chk.is_integer() == True:
                ans = ans + 1

    print(ans)



main_chk()

Submission status: Wrong Answer

Solution code:
n = input()
n = int(n)
a = []
tp = 0
for i in range(n):
  tp = input()
  tp = float(tp)
  a.append(tp)
ans = 0
for num in range(len(a)-1):
  p = a.pop(0)
  for n in a:
    if (n*p).is_integer() == True:
      ans+=1
print(ans)

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)

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

fras = sorted(set(d - int(d) for d in decs))
frac = {}
for d in decs:
    t = d - int(d)
    frac.setdefault(t, 0)
    frac[t] += c[d]

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

print(result)

Submission status: Wrong Answer

Solution code:
def cchange(c):
  if c == '0':
    return ''
  elif c [-1] == '0':
    c = cchange(c[:-1])
    return c
  else:
    return c

def count5(num,m):
  if num % 5 == 0:
    mm = count5(num//5,m+1)
    return mm
  else:
    return m
  
def count2(num,m):
  if num % 2 == 0:
    mm = count2(num//2,m+1)
    return mm
  else:
    return m

n = int(input())
l = [0]*n
for i in range(n):
  a = input()
  if not '.' in a:
    a = int(a)
    l[i] = [a, count5(a,0), count2(a,0)]
  else:
    b,c = a.split('.')
    c = cchange(c)
    if c == '':
      a = int(b)
      l[i] = [a, count5(a,0), count2(a,0)]
    else:
      a = int(b+c)
      l[i] = [a, count5(a,0)-len(c), count2(a,0)-len(c)]
      
count = 0
print('wa')

for i in range(n):
  for j in range(i+1,n):
    if l[i][1] + l[j][1] >= 0 and l[i][2] + l[j][2] >= 0:
      count += 1

print(count)

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(n):
    b=a[i]*a[j]
    if i<j and b==int(b):
      cou+=1
print(cou)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [float(input()) for i in range(N)]
e = 0.00000000000002
ans = 0

for i in range(N):
    for j in range(i + 1, N):
        if A[i] * A[j] < int(A[i] * A[j]) + e and A[i] * A[j] > int(A[i] * A[j]) - e:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from decimal import *

n = int(input())
ans = 0
vec = [Decimal(input()) for i in range(n)]
vec25 = [[0 for i in range(50)] for i in range(50)]  # 整数にするのに余っている2,5の数
for i in range(n):
    a = vec[i] * 1000000000
    num2 = -9
    num5 = -9
    while a%2 == 0:
        a //= 2
        num2 += 1
    while a%5 == 0:
        a //= 5
        num5 += 1
    vec25[num2][num5] += 1
for i in range(-9, 40): 
    for j in range(-9, 40):
        for k in range(max(-9, -i), 40):
            for l in range(max(-9, -j), 40):
                if i+k >= 0 and j+l >= 0 :
                    if i != k or j != l :
                        ans += vec25[i][j] * vec25[k][l]
                    else :
                        ans += vec25[i][j] * (vec25[i][j] - 1)

print(ans)

Submission status: Wrong Answer

Solution code:
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    while b > 0:
        a, b = b, a % b
    return a

n = int(input())
fractions = []

den_num_pair = dict()

for _ in range(n):
    s = input()
    di = 0
    l = len(s)
    while di < l and s[di] != '.':
        di += 1
    num = s[:di]
    if di + 1 < l:
        num += s[di+1:]
        den = 10 ** (l - di - 1)
    else:
        den = 1
    num = int(num)
    g = gcd(num, den)
    num //= g
    den //= g
    if den > 10000:
        continue
    fractions.append((num, den))
    if not den in den_num_pair:
        den_num_pair[den] = []
    den_num_pair[den].append(num)

count = 0
for num, den in fractions:
    di = 1
    while di * di <= num:
        if num % di == 0:
            dj = num // di
            if di in den_num_pair:
                for num_i in den_num_pair[di]:
                    if num_i % den == 0:
                        count += 1
            if di != dj and dj in den_num_pair:
                for num_j in den_num_pair[dj]:
                    if num_j % den == 0:
                        count += 1
        di += 1
    if den == 1:
        count -= 1
print(count // 2)

Submission status: Wrong Answer

Solution code:
n=int(input())
s=[float(input()) for i in range(n)]
ans_l=[]
for i in range(n):
    if float.is_integer(s[i]*10000):
        ans_l.append(s[i])
n=len(ans_l)
count=0
for i in range(n-1):
    for j in range(i+1,n):
        if (ans_l[i]*ans_l[j]).is_integer():
            #print(ans_l[i],ans_l[j])
            count+=1
            #ans_l.append(s[i]*s[j])
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
p, count = 1, 0
an, bn = [], []
for i in range(n):
    a = float(input())
    if not a.is_integer():
        bn.append(a)
    else:
        an.append(a)

an, bn = list(set(an)), list(set(bn))

for i in range(len(an)):
    for j in range(len(bn)):
        if (an[i] * bn[j]).is_integer():
            count += 1

pl = len(an)
for i in range(len(an)):
    p *= pl
    pl -= 1

print(p+count)

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 19 + 7
EPS = 10 ** -10

def gcd(a, b):
    while b: a, b = b, a % b
    return a

N = INT()
K = 10**9
L = 10**18
A = [0] * N
C = Counter()
for i in range(N):
    a = float(input())
    A[i] = int(a * K)
    C[gcd(A[i], L)] += 1

ans = 0
for k1, v1 in C.items():
    for k2, v2 in C.items():
        if k1 == k2:
            if k1*k2 % L == 0:
                ans += v1*(v1-1) // 2
        elif k1 < k2:
            if k1*k2 % L == 0:
                ans += v1 * v2
print(ans)

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(n):
    b=a[i]*a[j]
    if b==int(b):
      cou+=1
print(cou)

Submission status: Wrong Answer

Solution code:
#from pprint import pprint

N = int(input())


p = 19
q = 19

count = 0###両方9以上のやつ

data = [[0 for j in range(q)] for i in range(p)]
for i in range(N):
    A = int(float(input()) * (10**9))
    a = 0
    b = 0
    AA = A
    while AA%2 ==0:
        AA //=2
        a += 1
    AA = A
    while AA%5==0:
        AA //= 5
        b += 1
    data[min(a,18)][min(b,18)] += 1

    if a >= 9 and b >= 9:
        count += 1

S = [[0 for j in range(q)] for i in range(p)]

S[p-1][q-1] = data[p-1][q-1]

for i in range(p-2,-1,-1):
    S[i][q-1] = S[i+1][q-1] + data[i][q-1]

for i in range(q-2,-1,-1):
    S[p-1][i] = S[p-1][i+1] + data[p-1][i]

for i in range(p-2,-1,-1):
    for j in range(q-2,-1,-1):
        S[i][j] = data[i][j] + S[i+1][j] + S[i][j+1] - S[i+1][j+1]

ans = 0

for i in range(19):
    for j in range(19-i):
        if i == 9 and j == 9:
            continue
        ans += S[18-i][18-j] * data[i][j]

###和が18のものと和が18のものの組みは2回足されているので引く
for i in range(5):
    ans -= data[i][18-i] * data[18-i][i]

###
#ans += data[9][9]*(data[9][9]-1)//2 + data[9][9]*(S[9][9]-data[9][9])

ans += count*(count-1)//2

#pprint(data)
#pprint(S)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

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同士の重複に注意
    
    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:
from collections import Counter


class TrieNode:
    def __init__(self):
        self.edges = {}
        self.letter___count = Counter()

    def count_strings(self, word):
        curr_node = self
        for letter in word[:-1]:
            if letter not in curr_node.edges:
                return 0
            curr_node = curr_node.edges[letter]
        return curr_node.letter___count[word[-1]]

    def add(self, word):
        curr_node = self
        counts = Counter(word)
        for letter in word:
            for l in counts:
                curr_node.letter___count[l] += 1
            counts[letter] -= 1
            if counts[letter] == 0:
                counts.pop(letter)
            if letter not in curr_node.edges:
                curr_node.edges[letter] = TrieNode()
            curr_node = curr_node.edges[letter]


def main():
    n = int(input())
    strings = sorted([input()[::-1] for _ in range(n)], key=lambda x: -len(x))
    ans = 0
    trie = TrieNode()
    for word in strings:
        ans += trie.count_strings(word)
        trie.add(word)
    print(ans)


if __name__ == '__main__':
    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(n):
    b=a[i]*a[j]
    if b==int(b):
      cou+=1

Submission status: Wrong Answer

Solution code:
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 int(num * nums[j]) == num * nums[j]:
                ans += 1
    return ans


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

Submission status: Wrong Answer

Solution code:
import itertools
from decimal import Decimal
N = int(input())
grid = []
lis = []
count = 0
for i in range(N):
    array = input()
    grid.append(array)

for pair in itertools.combinations(grid, 2):
  result = 1
  for x in pair:
    result = result * float(x)
  if float(result) == int(result):
    count += 1
  else:
    pass

print(count)

Submission status: Wrong Answer

Solution code:
input_n = input()
N = int(input_n)
a = []
for i in range(N):
  input_a = input()
  input_a = float(input_a)
  a.append(input_a)

integer_counter = 0
for i in range(N):
  for j in range(N-i):
    if i != j+i:
      product = float(a[i])*float(a[j+i])
      if int(product) == product:
        integer_counter += 1
print(integer_counter)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
a = []
for i in range(n):
    a.append(float(input()) * 10 ** 9)

cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        if (((a[i] * a[j]) / 10 ** 18).is_integer()):
            cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
import bisect
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]

def main():
    N = I()
    mylist = [F() for i in range(N)]
    Int = []
    Float = []
    result = 0
    Int_len = 0
    for i in mylist:
        if i == int(i):
            Int_len += 1
        else:
            temp = 1/(i % 1)
            Float.append(temp)
    Float.sort()
    mylist.sort()
    result = int(Int_len*(Int_len-1)/2)
    for i in Float:
        index = bisect.bisect(mylist,i)
        for j in range(index,N):
            if mylist[j] % i == 0:
                result += 1
    print(result)
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
a = []
for i in range(n):
    a.append(float(input()) * 10 ** 9)

print(a)

cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        if (((a[i] * a[j]) / 10 ** 18).is_integer()):
            cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
import decimal
import numpy as np
input = sys.stdin.readline

N = int(input())
A = []
C2 = np.array([[0 for j in range(14)] for i in range(14)])  # 10countは9タス
C5 = np.array([[0 for j in range(14)] for i in range(14)])
C10 = np.zeros(14)
for _ in range(N):
    i = decimal.Decimal(input())
    c10, c2, c5 = 0, 0, 0
    while i % 1 != 0:
        c10 -= 1
        i *= 10
    while i % 10 == 0:
        c10 += 1
        i /= 10
    while i % 2 == 0:
        c2 += 1
        i /= 2
    while i % 5 == 0:
        c5 += 1
        i /= 5
    c2 = min(c2, 13)
    c5 = min(c5, 13)
    A.append((c10, c2, c5))
    C2[c10+9][c2] += 1
    C5[c10+9][c5] += 1
    C10[c10+9] += 1

ans = 0
for i in range(14):
    ans += C10[i]*np.sum(C10[18-i:])
    if i >= 9:
        ans -= C10[i]
    for j in range(18-i):
        if j >= 14:
            continue
        for k in range(1, 14):
            shouldhave = 18 - i - j
            if k >= shouldhave:
                ans += C2[i][k] * np.sum(C5[j][shouldhave:])
                ans += C5[i][k] * np.sum(C2[j][shouldhave:])

print(int(ans//2))

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
#整数と整数
#有限整数は、「2^t × 5^f」で表せる。
#A = sys.stdin.readlines()
MN = [[0 for i in range(33)] for i in range(33)]
#MN[i][j] = プラスi-9,マイナスi-9
for _ in range(N):
    a = input()
    two = 0
    five = 0
    ten = 0
    if "." in a:
        shosuten = a.index(".")
        ten = len(a) - shosuten - 1
        a = int("".join([hoge for hoge in a if hoge != "."]))
        two = ten
        five = ten
    else:
        a = int(a)
        two = 0
        five = 0  
    while a%5 == 0:
        a //= 5
        five -= 1
    while a%2 == 0:
        a //= 2
        two -= 1
    MN[two+16][five+16] += 1
    

ans = 0
selfu = 0
for two1 in range(33):
    for five1 in range(33):
        abe = MN[two1][five1]
        for two2 in range(33):
            for five2 in range(33):
                nana = MN[two2][five2]
                if two1 + two2 <=32 and five1 + five2 <= 32:
                    if two1 == two2 and five1 == five2:
                        if abe:
                            ans += abe*(nana-1)
                    else:
                        ans += abe*nana
print(ans//2)

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())
A = [float(input()) for _ in range(n)]

cnt = 0

aInt, aFlt = [], []
for a in A:
    if a.is_integer():
        aInt.append(a)
    else:
        aFlt.append(a)
        
le = len(aInt)
cnt += int(le * (le - 1) / 2)

for pair in itertools.combinations(aFlt, 2):
    if (pair[0] * pair[1]).is_integer():
        cnt += 1        

for a, b in itertools.product(aInt, aFlt):
    if (a * b).is_integer():
        cnt += 1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [input() for i in range(n)]
for i in range(n):
  if '.' in a[i]:
    a[i] = float(a[i])
  else:
    a[i] = int(a[i])
  
ans = 0
count = 0

print(a)
for i in range(n):
  for j in range(i + 1, n):
    ans = (a[i]*10) * (a[j]*10)
    ans = ans*0.01
    if isinstance(ans, int):
      count += 1
    elif ans.is_integer():
      count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
a = []
for i in range(n):
    a.append(float(input()) * 10 ** 9)

print(a)

cnt = 0
for i in range(n):
    for j in range(i + 1, n):
        if (((a[i] * a[j]) / 10 ** 18).is_integer()):
            print(a[i], a[j], (a[i] * a[j]) / 10 ** 18)
            cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
nums = []
for _ in range(n):
  nums.append(float(input()))
count = 0
for i, num in enumerate(nums):
  for j in range(i + 1, len(nums)):
    a = num * nums[j]
    if int(a) == a:
      print(a, num, nums[j])
      count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def primes(n):
    a = Counter()
    while n % 2 == 0:
        a[2]+=1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f]+=1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n]+=1
    return a

class BIT():#添字は1から始まることに注意
    def __init__(self, max_n):
        self.size = max_n + 1
        self.tree = [0] * self.size
        self.depth = self.size.bit_length()
        self.tot=0
        
    def initialize(self,seq):
        tree = self.tree
        size = self.size
        self.tot=0
        for i,x in enumerate(seq,1):
            self.tot+=x
            tree[i] += x
            j = i+(i&(-i))
            if j < size:
                tree[j] += tree[i]
        
    def __repr__(self):
        return self.tree.__repr__()
        
    def sum(self,i):
        tree = self.tree
        s = 0
        while i:
            s += tree[i]
            i -= i & -i
        return s
 
    def add(self, i, val):
        tree = self.tree
        size = self.size
        while i < size:
            tree[i] += val
            i += i & -i
        self.tot+=val
    
    def find(self,k):#k番目（最小は１）の要素,使うときは数列のサイズとbitのサイズを合わせること
        if k>self.tot: return self.size
        tree = self.tree; size = self.size
        x,sx = 0,0
        dx = 1 << (self.depth)
        for i in range(self.depth - 1, -1, -1):
            dx = (1 << i)
            if x + dx >= size:
                continue
            y = x + dx
            sy = sx + tree[y]
            if sy < k:
                x,sx = y,sy
        return x + 1

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(str, input().split())) #1行ベクトル
    A = tuple(input() for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    ans=0
    dp=[BIT(19) for _ in range(19)]
    for a in A:
        ta=0
        base=1
        dot=0
        for i in range(len(a)):
            ai=a[-1-i]
            if ai==".":
                dot=i
            else:
                ta+=base*int(ai)
                base*=10
        
        c=primes(ta)
        n2=min(18,c[2]+(9-dot))
        n5=min(18,c[5]+(9-dot))
        t2=18-n2
        t5=18-n5
        for i in range(t2,19):
            ans+=dp[i].sum(18-t5+1)
        #printe(n2,n5,ans)
        dp[n2].add(18-t5+1,1)
    print(ans)




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
count = 0
a_list = []
box =[]
for _ in range(n):
    num = float(input())
    a_list.append(num)

for i in a_list:
    for j in a_list:
        if float((i * j)) not in box:
            box.append(float(i * j))

for g in box:
    if g.is_integer():
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    n = int(input())
    a = [int(float(input().rstrip())*10**9) for _ in range(n)]
    ans = 0
    for i in range(len(a)):
        for k in range(i+1,len(a)):
            p = a[i]*a[k]%10**18
            print(a[i],a[k],p)
            if p == 0:
                ans += 1
    print(ans)

if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input())
a=[]
for i in range(n):
  #a.append(int(float(input())*1000000000))
  b=int(float(input())*1000000000)
  if b%100000==0:
    a.append(b)
n=len(a)
r=0
for i in range(0,n-1):
  for j in range(i+1,n):
    if (a[i]*a[j])%1000000000000000000==0:
      r=r+1
print(r)

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
G = []

for i in range(39):
    G.append([])
    for j in range(39):
        G[i].append(0)

ans = 0
    
for i in range(n):
    c2 = 0
    c5 = 0
    p = int(float(raw_input()) * (1e18))
    while (p%2==0):
        p/=2
        c2+=1
    while (p%5==0):
        p/=5
        c5+=1
    c2 = min(c2,36)
    c5 = min(c5,36)
    for j in range(37):
        for k in range(37):
            if (j+c2 >= 36 and k+c5 >= 36):
                ans += G[j][k]
    G[c2][c5] += 1
print ans

Submission status: Wrong Answer

Solution code:
import decimal 
n=int(input())
lst=[]
for k in range(n):
    a=float(input())
    lst.append(a)
count=0 
for i in range(0,n):
    for j in range(i+1,n):
        num=lst[i]*lst[j]
        num=str(num)
        if( decimal.Decimal(num) == decimal.Decimal(num).to_integral()):
            count+=1 
print(count)

Submission status: Wrong Answer

Solution code:
import decimal
N = int(input())
int_A = []
float_A = []
float_even_A = []  # 末尾が偶数か5のやつ
float_5_A = []
for n in range(N):
    a = input()
    a_number = float(a)
    if a_number % 1.0 > 0:
        if a[-1] == '5':
            float_5_A.append(a_number)
        elif a[-1] in ['2', '4', '6', '8']:
            float_even_A.append(a_number)
        elif a[-1] in ['1', '3', '5', '7', '9']:
            float_A.append(a_number)
        else:
            for _a in a[::-1]:
                if _a == '0':
                    continue
                elif _a in ['2', '4', '6', '8']:
                    float_even_A.append(a_number)
                elif _a == '5':
                    float_5_A.append(a_number)
    else:
        int_A.append(int(a_number))
cnt = 0
cnt += len(int_A) * (len(int_A) - 1) // 2
for int_a in int_A:
    for float_a in float_A:
        product = int_a * float_a
        if product % 1.0 == 0:
            cnt += 1
    for float_even_a in float_even_A:
        product = int_a * float_even_a
        if product % 1.0 == 0:
            cnt += 1
    for float_5_a in float_5_A:
        product = int_a * float_5_a
        if product % 1.0 == 0:
            cnt += 1

for float_5_a in float_5_A:
    for float_even_a in float_even_A:
        product = float_5_a * float_even_a
        if product % 1.0 == 0:
            cnt += 1
# print(f"int_A: {int_A}")
# print(f"float_A: {float_A}")
# print(f"float_even_A: {float_even_A}")
# print(f"float_5_A: {float_5_A}")
print(cnt)

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)

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

    f = a - int(a)
    t = bisect_left(ints, 1 / f)
    for j in range(t, len(ints)):
        b = ints[j]
        t = a * b
        if t == int(t):
            #print(a, b)
            result += c[a] * c[b]

print(result)

Submission status: Wrong Answer

Solution code:
input_n = input()
N = int(input_n)
a = []
for i in range(N):
  input_a = input()
  if '.' in input_a:
    counter = 0
    period = 0
    b = []
    for letter in input_a:
      if letter != '.':
        b.append(letter)
        counter += 1
      else:
        period = len(input_a) - 1 - counter
    input_a = ''.join(map(str, b))
    input_a = int(input_a)
    for j in range(period):
      input_a = input_a / 10
  a.append(input_a)

integer_counter = 0
for i in range(N):
  for j in range(N-i):
    if i != j+i:
      product = float(a[i])*float(a[j+i])
      if int(product) == product:
        integer_counter += 1
print(integer_counter)

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
  a = float(input())
  b = a * 10**5
  if b.is_integer()==True:
    l.append(a)
count = 0
for i in range(len(l)):
  for j in range(i+1,len(l)):
    an = l[i]*l[j]
    if an.is_integer()==True:
      count += 1
print(count)

Submission status: Wrong Answer

Solution code:
from math import gcd
n = int(input())
li = []
for i in range(n):
    s = input()
    if '.' in s:
        a, b = s.split('.')
        t = 10 ** len(b)
        li.append((int(a) * t + int(b), t))
    else:
        li.append((int(s), 1))
p = [[0] * 24 for _ in range(24)]
cnt = 0
for i in range(n):
    x, y = li[i]
    g = gcd(x, y)
    x //= g
    y //= g
    if y == 1:
        cnt += 1
    li[i] = x
    a1, b1 = 0, 0
    while x % 2 == 0:
        a1 += 1
        x //= 2
    while x % 5 == 0:
        b1 += 1
        x //= 5
    a2, b2 = 0, 0
    while y % 2 == 0:
        a2 += 1
        y //= 2
    while y % 5 == 0:
        b2 += 1
        y //= 5
    if a1 - a2 + 9 >= 24 or b1 - b2 + 9 >= 24:
        break
    p[a1 - a2 + 9][b1 - b2 + 9] += 1
ans = 0
for i in range(0, 24):
    for j in range(0, 24):
        for a in range(max(0, 18 - i), 24):
            for b in range(max(0, 18 - j), 24):
                ans += p[i][j] * p[a][b]
print((ans - cnt) // 2)

Submission status: Wrong Answer

Solution code:
n = int(input())

a = []

for i in range(n):
    temp = float(input()) * 10 ** 6
    a.append(temp)

count = 0

for i in range(len(a)):
    for j in range(len(a)):
        if i != j and i < j:
            temp = a[i] * a[j] / 10 ** 12
            #print(temp, int(temp))
            if temp - int(temp) == 0:
                count += 1

print(count)