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:
N = int(input())
A = [float(input()) for _ in range(N)]
A = [A[i]*1e9 for i in range(len(A))]
ans = [1 for i in range(N-1) for j in range(i+1,N) if A[i]*A[j]%1e18==0]
print(len(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 = bisect_left(decs, 1 / f)
    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]

    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:
N = int(input())
l = []
for i in range(N):
  a = float(input())
  b = a * 10**4
  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:
N = int(input())
A = [float(input()) for i in range(N)]
#A = [len(input()) for i in range(N)]
count = 0
B = []

for i in range(N):
    if A[i] >= 0.0001:
        B.append(A[i])

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

Submission status: Wrong Answer

Solution code:
import itertools
N=int(input())
A=[]
s=10**9
s2=s*s
for i in range(N):
  a=int(float(input())*s)
  if a%100000==0:
    A.append(a)
c=itertools.combinations(A,2)
ans=0
for i,j in c:
  if i*j%(s2)==0:
    ans+=1
print(ans)

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(19)] for i in range(19)]
#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 != "."]))
        int(a)
        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
    if two<=9 and five<=9:
        MN[two+9][five+9] += 1

ans = 0
selfu = 0
for two1 in range(19):
    for five1 in range(19):
        abe = MN[two1][five1]
        for two2 in range(19):
            for five2 in range(19):
                nana = MN[two2][five2]
                if two1 + two2 <=18 and five1 + five2 <= 18:
                    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:
n=int(input())
A=[]
for i in range(n):
    a=float(input())
    A.append(10**9*a)
x=0
for i in range(n-1):
    for j in range(n-i-1):
        b=A[i]*A[i+1+j]
        
        if b%(10**18)==0:
            x+=1
print(x)

Submission status: Wrong Answer

Solution code:
from math import *
#import sys 
#cin = sys.stdin()

cnt = [[0] * 20 for i in range(20)]

ans = 0
for _ in range(int(input())):
    t = float(input())
    #print(t)
    b = int(t * 1000000000.0)
    x, y = 0, 0
    while b % 2 == 0 and x < 18:
        x += 1
        b //= 2
    while b % 5 == 0 and y < 18:
        y += 1
        b //= 5
    #print(x, y)
    for i in range(20):
        for j in range(20):
            if (i + x >= 18) and (j + y >= 18):
                ans += cnt[i][j]
    cnt[x][y] += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction

N=int(input())
l={}

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

for i in range(N):
  x=Fraction(input())
  l.setdefault(x.denominator,[])
  l[x.denominator].append(x.numerator)
  factorization(x.denominator)
  factorization(x.numerator)

print(l)

Submission status: Wrong Answer

Solution code:
from math import *
#import sys 
#cin = sys.stdin()

cnt = [[0] * 20 for i in range(20)]

ans = 0
for _ in range(int(input())):
    t = float(input())
    print(t)
    b = int(t * 1000000000.0)
    x, y = 0, 0
    while b % 2 == 0 and x < 18:
        x += 1
        b //= 2
    while b % 5 == 0 and y < 18:
        y += 1
        b //= 5
    #print(x, y)
    for i in range(20):
        for j in range(20):
            if (i + x >= 18) and (j + y >= 18):
                ans += cnt[i][j]
    cnt[x][y] += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
r=0
for i in range(n):
  p=float(input())
  a.append(p)
for k in range(n):
  for m in range(n-k-1):
    x=a[k]*1000000000
    y=a[k+m+1]*1000000000
    l=x*y
    w=l%1000000000000000000
    if w==0:
      r=r+1
      
      
print(r)

Submission status: Wrong Answer

Solution code:
n = int(input())
T = 45
F = 19
a = [[0 for i in range(F)] for j in range(T)]
p = pow(10,9)
two_size = 18
five_size = 18
count = 0
for i in range(n):
    k = float(input()) * p
    two = 0
    five = 0
    while k % 2 == 0:
        two += 1
        k //= 2
    while k % 5 == 0:
        five += 1
        k //= 5
    t, f = two_size - two, five_size - five
    for x in range(t, T):
        for y in range(f, F):
            count += a[x][y]
    a[two][five] += 1
print(count)

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(19)] for i in range(19)]
#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 != "."]))
        int(a)
        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
    if two<9 and five<9:
        MN[two+9][five+9] += 1

ans = 0
selfu = 0
for two1 in range(19):
    for five1 in range(19):
        abe = MN[two1][five1]
        for two2 in range(19):
            for five2 in range(19):
                nana = MN[two2][five2]
                if two1 + two2 <=18 and five1 + five2 <= 18:
                    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 math
def prime(x):
  p = {}
  last = math.floor(x ** 0.5)
  if x % 2 == 0:
    cnt = 1
    x //= 2
    while x & 1 == 0:
      x //= 2
      cnt += 1
    p[2] = cnt
  for i in range(3, last + 1, 2):
    if x % i == 0:
      x //= i
      cnt = 1
      while x % i == 0:
        cnt += 1
        x //= i
      p[i] = cnt
  if x != 1:
    p[x] = 1
  return p


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

D = [[0] * 3 for _ in range(N)]

M2 = 0
M5 = 0
Md = 0

cnt = 0
for x in A:
  t = x.find(".")
  d = 4
  if t != -1:
    for i in range(t):
      x = x.rstrip("0")
    d -= (len(x) - t - 1)
    if d < 0:
      continue
    x = x.replace(".", "")
  p = prime(int(x))
  p2 = 0
  p5 = 0
  if 2 in p:
    p2 = p[2]
  if 5 in p:
    p5 = p[5]
  n = min(p2, p5)
  p2 -= n
  p5 -= n
  d += n
  D[cnt] = [p2, p5, d]
  cnt += 1
  M2 = max(M2, p2)
  M5 = max(M5, p5)
  Md = max(Md, d)

Md += 1
M = min(M2, M5) + 1
L = [[[0] * M for _ in range(2)] for _ in range(Md)]

ans = 0
for i in range(N):
  p2, p5, d = D[i]
  if d == 0: break
  if p2 == 0:
    n = 1
    t = p5
  else:
    n = 0
    t = p2
  for j in range(Md):
    for k in range(M):
      if d + j + min(t, k) >= 8:
        ans += L[j][1 - n][k]
      if d + j >= 8:
        ans += L[j][n][k]
  L[d][n][min(t, M - 1)] += 1

print(ans)

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 = []

for i in range(N):
    if A[i] > 0.0001:
        B.append(A[i])


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

Submission status: Wrong Answer

Solution code:
import sys
import copy
import math

count = int(sys.stdin.readline())
values = []
# values2 = []
for i in range(count):
    v = sys.stdin.readline()
    if v.find('.') == -1 or v.strip().strip('0')[-1] in ['.', '0', '2', '5', '4', '6', '8']:
        values.append(float(v))
        # values2.append(None)
    else:
        values.append(None)
        # values2.append(float(v))
result = 0
for i in range(count):
    for j in range(i+1, count):
        if values[i] is not None and values[j] is not None:
            v, _ = math.modf(values[i] * values[j])
            if v == 0:
                result += 1
        # elif values2[i] is not None and values2[j] is not None:
        #     v = values2[i] + values2[j]
        #     if int(v) == v:
        #         result += 1
print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(float(input()) for _ in range(n))

cnt = 0
for i in range(n-1):
    for j in range(i + 1, n):
        if i < j:
            num = a[i] * a[j]
            if num.is_integer():
                cnt += 1
#                 print(a[i], "_", a[j],"=", num)
print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
S =[float(input()) for k in range(N)]
a=0
for i in range(N):
  if (S[i]*10000%1 !=0):
    continue
  else:
    for j in range(N-i-1):
      if (S[i+j+1]*1000%1 ==0):
        if (S[i]*10*S[i+j+1]%10==0):
          a=a+1
          continue
        else:
          continue
      else:
        continue
      
print(a)

Submission status: Wrong Answer

Solution code:
class BIT:
    def __init__(self, n):
        #A1 ... AnのBIT(1-indexed)
        self.BIT = [0] * (n + 1)
        self.n = n

    #A1 ~ Aiまでの和 O(logN)
    def query(self, idx):
        res_sum = 0
        while idx > 0:
            res_sum += self.BIT[idx]
            idx -= idx & (-idx)
        return res_sum

    #Ai += x O(logN)
    def add(self, idx, x):
        while idx <= self.n:
            self.BIT[idx] += x
            idx += idx&(-idx)
        return
def get_int(f):
    if "." not in f:
        return int(f),0
    return int(f.replace(".","")),len(f)-f.index(".")-1
n = int(input())
p = []
for i in range(n):
    a, b = get_int(input())
    c, d = 0, 0
    while a % 2 == 0:
        c += 1
        a //= 2
    while a % 5 == 0:
        d += 1
        a //= 5
    c -= b
    d -= b
    p.append((c, d))
p.sort()
now = n - 1
t = BIT(200)
ans = 0
for i in range(n):
    for j in range(now, i, -1):
        if p[i][0] + p[j][0] >= 0:
            t.add(-p[j][1] + 100, 1)
            now -= 1
        else:
            break
    if now < i:
        t.add(-p[j][1] + 100, -1)
    ans += max(0, t.query(100 + p[i][1]))

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())

a = []

for i in range(n):
    temp = float(input())
    a.append(temp * 10 ** 6)
    
a = np.array(a)
a2 = [a] * n

b = []
for i in range(n):
    temp = [a[i]] * n
    b.append(temp)

a2 = np.ravel(a2)
b = np.ravel(b)


c = a2 * b


skip = []
base = 0
for i in range(n):
    skip.append(i + base)
    count = base + i
    while base < count:
        count -= 1
        skip.append(count)
    base += n

hit = []
count = 0
for i in range(len(c)):
    if i not in skip:
        temp = c[i] / 10 ** 12
        #print(temp, int(temp))
        result = temp - int(temp)
        if result == 0:
            count += 1
            hit.append(temp)

print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
r=0
for i in range(n):
  p=float(input())
  a.append(p)
for k in range(n):
  for m in range(n-k-1):
    x=a[k]*1000000000
    y=a[k+m+1]*1000000000
    l=x*y
    print(l)
    w=l%1000000000000000000
    if w==0:
      r=r+1
      
      
print(r)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction

N=int(input())
l={}

for i in range(N):
  x=Fraction(input())
  l[x.denominator]=1
print(l)

Submission status: Wrong Answer

Solution code:
import math as math
n=int(input())
l=[]
c=0
for i in range(n):
    m=input()
    l.append(float(m))
for i in range(n-1):
    for j in range(i+1,n):
        if (l[i]*l[j]).is_integer()==True:
            c=c+1    
print(c)

Submission status: Wrong Answer

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

ans = [[0] * N for n in range(N)]

for i in range(N):
    for j in range(i+1, N):
        if ans[i][j] == 0:
            ans[i][j] = (A[i] * A[j])

count = 0
for i in range(N):
    for j in range(i + 1, N):
        if ans[i][j].is_integer() and ans[i][j] != 0:
            count += 1
# print(ans)
print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
numList = []
result = []

user = int(input())
inputCount = user
count = 0

for i in range(inputCount):
    user = float(input())
    numList.append(user)

for i in range( len(numList) ):
    for j in range(len(numList)  - i - 1):
        result.append(float.is_integer( numList[i] * numList[i + j + 1]))

aaa = list(filter(lambda x: x == True, result))
print(len(aaa),end="")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [input() for i in range(N)]
a = [float(n) for n in A]
count=0
for i in range(len(a)):
    #print(a[i],'s')
    for j in range(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:
import numpy as np
n = int(input())
a = np.array([input() for _ in range(n)], dtype=np.float)


ans = 0
temp = a[0]

for i in range(1, n):
    temp = temp * a[i]
    if temp.is_integer():
        ans += 1


print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction

N=int(input())
l={}

for i in range(N):
  x=Fraction(input())
  print(x.numerator)
  print(x.denominator)

Submission status: Wrong Answer

Solution code:
import bisect as bi
n=int(input())
l=[input() for i in range(n)]
sto=[]
numl=[[0 for j in range(19)] for i in range(19)]
intcnt=0
for i in range(n):
    s=l[i]
    pal=[0,0]
    if "." not in s:
        intcnt+=1
    else:
        cs=len(s)-s.index(".")-1
        pal=[-cs,-cs]
    N=int(s.replace(".",""))
    while N%5 == 0:
        N//=5
        pal[0]+=1
    while N%2 == 0:
        N//=2
        pal[1]+=1
    numl[min(18,pal[0]+9)][min(18,pal[1]+9)]+=1
    sto.append(pal)
ans=0
accnuml=[[0 for i in range(20)] for j in range(20)]
for i in range(1,20):
    for j in range(1,20):
        accnuml[i][j]=accnuml[i][j-1]+accnuml[i-1][j]-accnuml[i-1][j-1]+numl[i-1][j-1]
for i in range(n):
    x,y=sto[i][0],sto[i][1]
    ans+=n-(accnuml[min(max(0,-x+9),18)][-1]+accnuml[-1][min(max(0,-y+9),18)]-accnuml[min(18,max(0,-x+9))][min(18,max(0,-y+9))])
print((ans-intcnt)//2)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
N, *A = open(0).read().split()


def fact(n):
    cnt2 = cnt5 = 0
    for _ in range(18):
        if n % 2:
            break
        n //= 2
        cnt2 += 1
    for _ in range(18):
        if n % 5:
            break
        n //= 5
        cnt5 += 1
    return cnt2, cnt5


def toid(c2, c5):
    c2 = min(18, c2)
    c5 = min(18, c5)
    return c2 * 19 + c5


table = [0]*361

for a in A:
    if '.' in a:
        a, b = a.split('.')
        cnt2 = cnt5 = 9 - len(b)

        a = int(a)
        c2, c5 = fact(a)
        cnt2 += c2
        cnt5 += c5

        b = int(b)
        c2, c5 = fact(b)
        cnt2 += c2
        cnt5 += c5

        id = toid(cnt2+c2, cnt5+c5)

    else:
        cnt2 = 9
        cnt5 = 9
        a = int(a)
        c2, c5 = fact(a)
        cnt2 += c2
        cnt5 += c5

        id = toid(cnt2+c2, cnt5+c5)

    table[id] += 1

acc = [[0]*19 for _ in [0]*19]
ans = 0

for i in range(19):
    acc[i][18] = table[toid(i, 18)]
    for j in range(17, -1, -1):
        acc[i][j] = acc[i][j+1] + table[toid(i, j)]

for i in range(19):
    acc[18][i] = table[toid(18, i)]
    for j in range(17, -1, -1):
        acc[j][i] = acc[j+1][i] + table[toid(j, i)]

for i in range(19):
    for j in range(19):
        x = acc[18-i][18-j]
        if i >= 9 and j >= 9:
            x -= 1
        ans += table[toid(i, j)] * x
print(ans)

Submission status: Wrong Answer

Solution code:
from math import *
#import sys 
#cin = sys.stdin()

cnt = [[0] * 19 for i in range(19)]

ans = 0
for _ in range(int(input())):
    t = float(input())
    b = int(t * 1000000000.0)
    x, y = 0, 0
    while b % 2 == 0 and x < 18:
        x += 1
        b //= 2
    while b % 5 == 0 and y < 18:
        y += 1
        b //= 5
    #print(x, y)
    for i in range(19):
        for j in range(19):
            if i + x >= 18 and j + y >= 18:
                ans += cnt[i][j]
    cnt[x][y] += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from decimal import *
N = int(input())
A = []
for i in range(N):
    a = float(input())
    A.append(a)

count = 0
for i in range(N):
    for j in range(i+1, N):
        if isinstance(A[i] * A[j], int):
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
#N = 1

A = [math.modf(float(input())*1000) for _ in range(N)]


counter = 0
for i in range(N-1):
	for j in range(i+1, N):
		num = (A[i][0]*A[j][1] + A[i][1]*A[j][0] + A[i][1]*A[j][1])
		#print(num)
		if num%1000000==0:
			counter += 1
print(counter)

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = []
l5 = []
l2 = []
for i in range(0, n):
    tmp = float(input()) * 1e9
    lst.append(int(tmp))

sol = 0
for i in range(0, n - 1):
    for j in range(i + 1, n):
        mul = lst[i] * lst[j]
        if mul % 1e18 == 0:
            sol += 1

print(sol)

Submission status: Wrong Answer

Solution code:
import math as ma
l = []
n = int (input ())
for i in range (n):
  a = input ()
  l.append (a)
l = [float(s) for s in l]
n = len (l)
z = 0
x = 0
y = 1
while x < n:
  while y < n:
    if l[x]*l[y] == ma.ceil (l[x]*l[y]):
      z += 1
    y += 1
  x += 1
  y = x+1
print (z)

Submission status: Wrong Answer

Solution code:
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    n = ii()
    a = []
    ans = 0
    for i in range(n):
        tmp = input()
        ketaage = 0
        if '.' in tmp:
            cnt = 1
            while tmp[-cnt] != '.':
                cnt += 1
            ketaage = cnt - 1
            tmp = tmp[:-cnt] + tmp[-cnt + 1:]
        tmp = int(tmp)
        while tmp % 10 == 0:
            ketaage -= 1
            tmp //= 10
        tcnt = 0
        fcnt = 0
        while tmp % 2 == 0:
            tcnt += 1
            tmp //= 2
        if tcnt == 0:
            while tmp % 5 == 0:
                fcnt += 1
                tmp //= 5
        a.append([tcnt, fcnt, ketaage])
    tlist = []
    flist = [[0 for i in range(100)] for j in range(100)]
    tlistlist = [0 for i in range(100)]

    seisuucnt = 0
    fseisuucnt = 0

    for i in range(n):
        if a[i][1] == 0:
            tlist.append([a[i][0], a[i][2]])

            if a[i][2] <= 0:
                seisuucnt += 1
                tlistlist[a[i][2] + 20] += 1
        else:
            flist[a[i][2] + 20][a[i][1]] += 1
            if a[i][2] <= 0:
                fseisuucnt += 1
    for i in range(1, 50):
        tlistlist[i] += tlistlist[i - 1]

    for tmp in range(50):
        for i in range(1, 50):
            flist[tmp][49 - i] += flist[tmp][49 - i + 1]
    for tmp in tlist:
        keta = tmp[1]
        tcnt = tmp[0]
        for i in range(-5, 22):
            if keta + i > tcnt:
                break
            ans += flist[i + 20][max(0, keta + i)]


#            print(tmp, keta, i, flist[i + 10][max(0, keta + i)],
#                  tlistlist[10 - keta])
        ans += tlistlist[20 - keta]

    if seisuucnt > 0:
        ans -= (seisuucnt * (seisuucnt - 1)) // 2
        ans -= seisuucnt
    if fseisuucnt > 0:
        ans += (fseisuucnt * (fseisuucnt - 1)) // 2
    print(ans)

main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

from collections import Counter

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def calc(b, d25):
    d2, d5 = -d25[0], -d25[1]
    while b%2 == 0:
        d2 += 1
        b //= 2
    while b%5 == 0:
        d5 += 1
        b //= 5
    return (d2, d5)

def main():
    n = ri()
    ndic = Counter()
    ans = 0
    for i in range(n):
        a = input()
        d = a.split(".")
        if len(d) == 1:
            m = 0
        else:
            m = len(d[1])
        d25 = [m, m]
        b = int(a.replace(".", ""))
        c25 = calc(b, d25)
        if c25[0] == -9 and c25[1] == -9:
            continue
        for e in ndic:
            if c25[0] + e[0] >= 0 and c25[1] + e[0] >= 0:
                ans += ndic[e]
        ndic[c25] += 1
    print(ans)

if __name__ == '__main__':
    main()

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)):
  n = num + 1
  for idx in range(len(a)-num-1):
    if (a[num]*a[idx+n]).is_integer() == True:
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
from decimal import Decimal
n = int(input())
int_list = []
int_count = 0
float_list = []
count = 0
for i in range(n):
    num = Decimal(input())
    if num == int(num):
        count+=int_count
        int_count += 1
        for flt_num in float_list:
            flt = num*flt_num
            if flt == int(flt):
                count += 1
        int_list.append(num)
    else:
        if (1/num) == int(1/num):
            for int_num in int_list:
                flt = num*int_num
                if flt == int(flt):
                    count += 1
        else:
            for flt_num in float_list:
                flt = num*flt_num
                if flt == int(flt):
                    count += 1
        float_list.append(num)
print(count)

Submission status: Wrong Answer

Solution code:
import bisect as bi
n=int(input())
l=[input() for i in range(n)]
sto=[]
numl=[[0 for j in range(19)] for i in range(19)]
intcnt=0
for i in range(n):
    s=l[i]
    pal=[0,0]
    if "." not in s:
        intcnt+=1
    else:
        cs=len(s)-s.index(".")-1
        pal=[-cs,-cs]
    N=int(s.replace(".",""))
    while N%5 == 0:
        N//=5
        pal[0]+=1
    while N%2 == 0:
        N//=2
        pal[1]+=1
    numl[min(18,pal[0]+9)][min(18,pal[1]+9)]+=1
    sto.append(pal)
ans=0
accnuml=[[0 for i in range(20)] for j in range(20)]
for i in range(1,20):
    for j in range(1,20):
        accnuml[i][j]=accnuml[i][j-1]+accnuml[i-1][j]-accnuml[i-1][j-1]+numl[i-1][j-1]
for i in range(n):
    x,y=sto[i][0],sto[i][1]
    ans+=n-(accnuml[min(max(0,-x+9),18)][-1]+accnuml[-1][min(max(0,-y+9),18)]-accnuml[min(18,-x+9)][min(18,-y+9)])
print((ans-intcnt)//2)

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)
    Z=0
    S=0

    
    for _ in range(N):
        c=input()
        if float(c)==0:
            Z+=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)
                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)) + Z*(N-Z)*2 + (Z*(Z-1))
    
    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]
    
        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 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)

print(intc)
result = intc * (intc - 1) // 2
for i in range(len(decs)):
    a = decs[i]
    if a < 1:
        t = bisect_left(decs, 1 / a)
    else:
        t = i + 1
    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]

    if a < 1:
        t = bisect_left(ints, 1 / a)
    else:
        t = 0
    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:
N = int(input())
a = [float(input()) for i in range(N)]
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        if (a[i]*a[j]).is_integer():
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
li = []
cout = 0
for _ in range(n):
    j = float(input())
    if li:
        for i in li:
            if float(i*j) == float(int(i*j)):
                cout+=1
    li.append(j)
print(cout)

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)
    Z=0
    S=0

    
    for _ in range(N):
        c=input()
        if float(c)==0:
            Z+=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)
                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)) + Z*(N-Z)*2
    
    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]
    
        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:
a=[]
for n in range(int(input())):
    ai=float(input())
    a.append(ai)
cnt=0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        res=a[i]*a[j]
        if(res==int(res)):
            cnt+=1
print(cnt)