Problem:


Score : 300 points

Problem Statement

You are given N real values A_1, A_2, \ldots, A_N.
Compute the number of pairs of indices (i, j)
    such that i < j and the product A_i \cdot A_j is integer.

Constraints

2 \leq N \leq 200\,000

0 < A_i < 10^4

A_i is given with at most 9 digits after the decimal.

Input

Input is given from Standard Input in the following format.

N
A_1
A_2
\vdots
A_N

Output

Print the number of pairs with integer product A_i \cdot A_j (and i < j).

Sample Input 1

5
7.5
2.4
17.000000001
17
16.000000000

Sample Output 1

3

There are 3 pairs with integer product:

7.5 \cdot 2.4 = 18

7.5 \cdot 16 = 120

17 \cdot 16 = 272

Sample Input 2

11
0.9
1
1
1.25
2.30000
5
70
0.000000001
9999.999999999
0.999999999
1.000000001

Sample Output 2

8



Sample input:
5
7.5
2.4
17.000000001
17
16.000000000


Sample output:
3

Submission status: Wrong Answer

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

N=int(readline())

# かけあわせて2が18回、5が18回以上出てくる組を数える
# C[i][j] = 2がi回、5がj回出てくる数の個数 19 * 19なので小さい

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

for i in range(N):
  a = int(float(readline()) * (10 ** 9))
  cnt2 = 0
  while a % 2 == 0:
    cnt2 += 1
    a //= 2
    if cnt2 == 18:
      break
  cnt5 = 0
  while a % 5 == 0:
    cnt5 += 1
    a //= 5
    if cnt5 == 18:
      break
  C[cnt2][cnt5] += 1
  
ans = 0
for i in range(19):
  for j in range(19):
    for p in range(19):
      for q in range(19):
        if i == p and j == q:
          continue
        if i + p >= 18 and j + q >= 18:
          ans += C[i][j] * C[p][q]
          
ans //= 2
for i in range(19):
  for j in range(19):
    if i * 2 >= 18 and j * 2 >= 18:
      ans += (C[i][j] * (C[i][j] - 1)) // 2
          
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=[]

bo=[[0 for i in range(19)] for i in range(19)]
stc=[]
natu=0

def nankai(x,d):
    cnt=0
    while x%d==0 and x>=1 and cnt<9:
       cnt+=1
       x=x//d
    return cnt

def bonankai(p,q):
    return nankai(p,2)-nankai(q,2)+9,nankai(p,5)-nankai(q,5)+9


for i in range(n):
    r=input()
    if "." in r:
        tag=r.index(".")
        p=int(r[:tag]+r[tag+1:])
        q=pow(10,len(r[tag+1:]))
        res=bonankai(p,q)
        bo[res[0]][res[1]]+=1
        #print(p,q)
        stc.append(res)
    else:
        p=int(r)
        q=1
        res=bonankai(p,q)
        bo[res[0]][res[1]]+=1
        #print(p,q)
        stc.append(res)
        natu+=1

for i in range(17,-1,-1):
    for q in range(19):
        bo[i][q]+=bo[i+1][q]

for q in range(17,-1,-1):
    for i in range(19):
        bo[i][q]+=bo[i][q+1]

ans=0
for que in stc:
    ans+=bo[18-que[0]][18-que[1]]
ans-=natu
ans//=2
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
from collections import defaultdict
from fractions import Fraction


def solve(*args: str) -> str:
    n = int(args[0])
    D = defaultdict(list)

    for a in args[1:]:
        frac = Fraction(a)
        if frac.denominator <= 10000:
            D[frac.denominator].append(frac.numerator)

    ret = 0
    I = sorted(D.items(), key=lambda x: x[0])

    if I[0][0] == 1:
        m = len(I[0][1])
        ret += m*(m-1)//2
        I.append(I.pop())

    while I:
        l_den, nums = I.pop()
        for r_den, DN in I:
            for l_num in nums:
                if l_num % r_den != 0:
                    continue

                for r_num in DN:
                    if r_num % l_den == 0:
                        # print(l_num/l_den, r_num/r_den)
                        ret += 1

    return str(ret)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Wrong Answer

Solution code:
def prime(n):
    ans=[0,0]
    n*=10**9
    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=[prime(a[i]) for i in range(n)]
ans=0

d=[[0 for k in range(44)] for l in range(19)]

for i in range(len(b)):
    for k in range(44):
        for l in range(19):
            if b[i][0]>=k and b[i][1]>=l:
                d[l][k]+=1

for i in range(len(b)):
    ans+=d[max([0,-b[i][1]+18])][max([0,-b[i][0]+18])]
    if b[i][0]>=9 and b[i][1]>=9:
        ans-=1
print(ans//2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
B = []
C2 = [0] * N
C5 = [0] * N
for i in range(N):
    s = str(input())
    A.append(s)
    ok = False
    cnt = 0
    l = len(A[-1])
    for j in range(l):
        if A[-1][j] == '.':
            ok = True
            cnt = j
    if ok:
        # 11桁になるまで+0
        if cnt == 1:
            while len(A[-1]) < 11:
                A[-1] += "0"
        # 12
        elif cnt == 2:
            while len(A[-1]) < 12:
                A[-1] += "0"
    else:
        A[-1] += ".000000000"
    tmp = ""
    for j in range(len(A[i])):
        if A[i][j] == '.':continue
        tmp += A[i][j]
    B.append(int(tmp))
    tmp = B[i]
    tmp2 = B[i]
    while tmp > 0:
        if tmp % 2 == 0:
            tmp //= 2
            C2[i] += 1
        else:
            break
    while tmp2 > 0:
        if tmp % 5 == 0:
            tmp //= 5
            C5[i] += 1
        else:
            break

Cc = [[] for _ in range(19)]
for i in range(N):
    Cc[min(18, C2[i])].append(C5[i])

for i in range(19):
    Cc[i].sort()

ans = 0
for i in range(N):
    # 2がC2[i]個 -> 相手は最低18-C2[i]かつ、18 - C5[i]以上の個数
    M = 18 - C5[i]
    for j in range(max(0,18-C2[i]), 19):
        ok = -1
        ng = len(Cc[j])
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            if Cc[j][mid] >= M:
                ok = mid
            else: ng = mid
        ans += ok+1

for b in B:
    if b % 1000000000 == 0:
        ans -= 1

print(ans//2)

Submission status: Wrong Answer

Solution code:
n= int(input())

arr = [float(input()) for _ in range(n)]
c = 0

for i in range(n):
  for j in range(i+1,n):
    s = arr[i]*arr[j]
    if s==int(s):
      c+=1

print(c)

Submission status: Wrong Answer

Solution code:
n = int(input())

lst = [[0 for _ in range(25)] for _ in range(25)]
int_cnt = 0
for _ in range(n):
    a = input()
    if "." in a:
        pos = a.index(".")
        a1, a2 = a[:pos], a[pos + 1:]
        l = len(a2)
        a = a1 + a2
        a = int(a)
        a *= 10 ** (9 - l)
    else:
        a = int(a)
        int_cnt += 1
        a *= 10 ** 9
    t = 0
    while a % 2 == 0:
        t += 1
        a //= 2
    f = 0
    while a % 5 == 0:
        f += 1
        a //= 5
    t = min(t, 24)
    f = min(f, 24)
    lst[t][f] += 1


 
ans = 0
for i in range(25):
    for j in range(25):
        for k in range(25):
            for l in range(25):
                if i + j >= 18 and k + l >= 18:
                    ans += lst[i][k] * lst[j][l]
print((ans - int_cnt) // 2)

Submission status: Wrong Answer

Solution code:
def prime(n):
    ans=[0,0]
    n*=10**9
    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=[prime(a[i]) for i in range(n)]
ans=0

d=[[0 for k in range(44)] for l in range(19)]

for i in range(len(b)):
    for k in range(44):
        for l in range(19):
            if b[i][0]>=k and b[i][1]>=l:
                d[l][k]+=1

for i in range(len(b)):
    ans+=d[-b[i][1]+18][-b[i][0]+18]
    if b[i][0]>=9 and b[i][1]>=9:
        ans-=1
print(ans//2)

Submission status: Wrong Answer

Solution code:
n = int(input())

lst = [[0 for _ in range(19)] for _ in range(19)]
int_cnt = 0
for _ in range(n):
    a = input()
    if "." in a:
        pos = a.index(".")
        a1, a2 = a[:pos], a[pos + 1:]
        l = len(a2)
        a = a1 + a2
        a = int(a)
        a *= 10 ** (9 - l)
    else:
        a = int(a)
        int_cnt += 1
        a *= 10 ** 9
    t = 0
    while a % 2 == 0:
        t += 1
        a //= 2
    f = 0
    while a % 5 == 0:
        f += 1
        a //= 5
    t = min(t, 18)
    f = min(f, 18)
    lst[t][f] += 1


 
ans = 0
for i in range(19):
    for j in range(19):
        for k in range(19):
            for l in range(19):
                if i + j >= 18 and k + l >= 18:
                    ans += lst[i][k] * lst[j][l]
print((ans - int_cnt) // 2)

Submission status: Wrong Answer

Solution code:
cnt = 100
res = []

def one():
    global cnt
    global res
    res.append(f"< 2 0 {cnt}")
    cnt += 1
    return cnt - 1

def twice(x):
    global cnt
    global res
    res.append(f"+ {x} {x} {cnt}")
    cnt += 1
    return cnt - 1

def plus(x, y):
    global cnt
    global res
    res.append(f"+ {x} {y} {cnt}")
    cnt += 1
    return cnt - 1

def gt(x, y):
    global cnt
    global res
    res.append(f"< {x} {y} {cnt}")
    cnt += 1
    return cnt - 1

def tmp():
    global cnt
    cnt += 1
    return cnt - 1

def mult(x, y):
    global one
    global cnt
    global res
    res.append(f"< {x} {one} {cnt}")
    res.append(f"< {cnt} {y} {cnt + 1}")
    cnt += 2
    return cnt - 1

A = 0
B = 1
zero = tmp()
one = one()
two = twice(one)
four = twice(two)
eight = twice(four)
A4 = gt(eight, plus(A, one))
A3 = gt(plus(four, twice(twice(twice(A4)))), plus(A, one))
A2 = gt(plus(two, plus(twice(twice(twice(A4))), twice(twice(A3)))), plus(A, one))
A1 = gt(plus(one, plus(plus(twice(twice(twice(A4))), twice(twice(A3))), twice(A2))), plus(A, one))

B4 = gt(eight, plus(B, one))
B3 = gt(plus(four, twice(twice(twice(B4)))), plus(B, one))
B2 = gt(plus(two, plus(twice(twice(twice(B4))), twice(twice(B3)))), plus(B, one))
B1 = gt(plus(one, plus(plus(twice(twice(twice(B4))), twice(twice(B3))), twice(B2))), plus(B, one))

A1B1 = mult(one, mult(A1, B1))
A1B2 = mult(one, mult(A1, B2))
A1B3 = mult(one, mult(A1, B3))
A1B4 = mult(one, mult(A1, B4))

A2B1 = mult(one, mult(A2, B1))
A2B2 = mult(one, mult(A2, B2))
A2B3 = mult(one, mult(A2, B3))
A2B4 = mult(one, mult(A2, B4))

A3B1 = mult(A3, B1)
A3B2 = mult(A3, B2)
A3B3 = mult(A3, B3)
A3B4 = mult(A3, B4)

A4B1 = mult(A4, B1)
A4B2 = mult(A4, B2)
A4B3 = mult(A4, B3)
A4B4 = mult(A4, B4)

AB1 = A1B1
AB2 = plus(A1B2, A2B1)
AB3 = plus(plus(A1B3, A2B2), A3B1)
AB4 = plus(plus(A1B4, A2B3), plus(A3B2, A4B1))
AB5 = plus(plus(A2B4, A3B3), A4B2)
AB6 = plus(A3B4, A4B3)
AB7 = A4B4

t1 = AB1
t2 = twice(AB2)
t3 = twice(twice(AB3))
t4 = twice(twice(twice(AB4)))
t5 = twice(twice(twice(twice(AB5))))
t6 = twice(twice(twice(twice(twice(AB6)))))
t7 = twice(twice(twice(twice(twice(twice(AB7))))))

ans = plus(plus(plus(t1, t2), plus(t3, t4)), plus(plus(t5, t6), t7))
res.append(f"+ 2 {ans}  2")

print(len(res))
for i in res:
    print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())

lst = [[0 for _ in range(19)] for _ in range(19)]
int_cnt = 0
for _ in range(n):
    a = float(input())
    a *= 10 ** 9
    a = int(a)
    t = 0
    while a % 2 == 0:
        t += 1
        a //= 2
    f = 0
    while a % 5 == 0:
        f += 1
        a //= 5
    t = min(t, 18)
    f = min(f, 18)
    lst[t][f] += 1

    if t >= 9 and f >= 9:
        int_cnt += 1
 
ans = 0
for i in range(19):
    for j in range(19):
        for k in range(19):
            for l in range(19):
                if i + j >= 18 and k + l >= 18:
                    ans += lst[i][k] * lst[j][l]
print((ans - int_cnt) // 2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
A2 = []
A5 = []
for i in range(N):
    A.append(int(float(input())*10**9))
    count2 = 0
    count5 = 0
    for _ in range(18):
        if A[i] % 2 == 0:
            count2 += 1
            A[i] /= 2
        else:
            break
    for _ in range(18):
        if A[i] % 5 == 0:
            count5 += 1
            A[i] /= 5
        else:
            break
    A2.append(count2)
    A5.append(count5)
ans=0
for i in range(N):
    for j in range(i+1,N):
        if A2[i] + A2[j] >= 18 and A5[i] + A5[j] >= 18:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
B = []
C2 = [0] * N
C5 = [0] * N
for i in range(N):
    s = str(input())
    A.append(s)
    ok = False
    cnt = 0
    l = len(A[i])
    for j in range(l):
        if A[i][j] == '.':
            ok = True
            cnt = j
    if ok:
        # 11桁になるまで+0
        if cnt == 1:
            while len(A[i]) < 11:
                A[i] += "0"
        # 12
        elif cnt == 2:
            while len(A[-1]) < 12:
                A[i] += "0"
    else:
        A[i] += ".000000000"
    tmp = ""
    for j in range(len(A[i])):
        if A[i][j] == '.':continue
        tmp += A[i][j]
    B.append(int(tmp))
    tmpp = B[i]
    tmp2 = B[i]
    while tmpp > 0:
        if tmpp % 2 == 0:
            tmpp //= 2
            C2[i] += 1
        else:
            break
    while tmp2 > 0:
        if tmp2 % 5 == 0:
            tmp2 //= 5
            C5[i] += 1
        else:
            break
Cc = [[0] * 19 for _ in range(19)]

for i in range(N):
    Cc[min(18, C2[i])][min(18, C5[i])]+=1

ans = 0
for i in range(N):
    l2 = max(0, 18 - C2[i])
    l5 = max(0, 18 - C5[i])
    for j in range(l2, 19):
        for k in range(l5, 19):
            ans += Cc[j][k]

for b in B:
    if b % 1000000000 == 0:
        ans -= 1

print(ans//2)

Submission status: Wrong Answer

Solution code:
import math
n=int(input())
a=[float(input()) for _ in range(n)]

l_int=[]
l_2=[]
l_4=[]
l_5=[]
l_8=[]
l_10=[]
l_100=[]
l_1000=[]
l_even=[]
ans=0
for x in a:
    if int(x)==x:l_int.append(x)
    else:
        ie=math.floor(x*10**9-int(x)*10**9)
        e=ie/(10**9)
        if e==0.2 or e==0.4 or e==0.6 or e==0.8 :l_even.append(x)
        if e==0.5:l_2.append(x)
        if e==0.25:l_4.append(x)
        if e==0.2:l_5.append(x)
        if e==0.125:l_8.append(x)

        if ie/1000==ie//1000:l_1000.append(x)
        elif ie/100==ie//100:l_100.append(x)
        elif ie/10==ie//10:l_10.append(x)
        
ans+=len(l_int)*(len(l_int)-1)/2+len(l_2)*len(l_even)

for x in l_int:
    if x==1:continue
    if x//8==x/8:ans+=len(l_8)
    if x//5==x/5:ans+=len(l_5)
    if x//4==x/4:ans+=len(l_4)
    if x//2==x/2:ans+=len(l_2)

    if x//1000==x/1000:ans+=len(l_1000)
    if x//100==x/100:ans+=len(l_100)
    if x//10==x/10:ans+=len(l_10)

print(int(ans))

Submission status: Wrong Answer

Solution code:
import pprint
N=int(input())
l2=[]
bit2=50
bit5=22
#table=[[0 for _ in range(20)] for _ in range(15)]
#table=[[0 for _ in range(45)] for _ in range(20)]
table=[[0 for _ in range(bit2)] for _ in range(bit5)]
for i in range(N):
    n=float(input())
    #print(n)
    n=int(n*pow(10,9))
    count2=0
    count5=0
    #print(n,kake)
    while n%2==0:
        n=n//2
        count2=count2+1
    while n%5==0:
        n=n//5
        count5=count5+1
    table[count5][count2]=table[count5][count2]+1
    l2.append([count2,count5])
#pprint.pprint(table)
#print(l2)
ans=0
for i in range(bit5):
    for j in range(bit2):
        num=table[i][j]
        min2=max(0,18-j)
        min5=max(0,18-i)
        cnt=0
        if num>0:
            #print(min2,min5,i,j,num)
            for k in range(min5,bit5):
                for l in range(min2,bit2):
                    cnt=cnt+table[k][l]
            if (min2<=j)and(min5<=i):
                cnt=cnt-1
            ans=ans+num*cnt
            #print(ans)
print(ans//2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
B = []
C2 = [0] * N
C5 = [0] * N
for i in range(N):
    s = str(input())
    A.append(s)
    ok = False
    cnt = 0
    l = len(A[-1])
    for j in range(l):
        if A[-1][j] == '.':
            ok = True
            cnt = j
    if ok:
        # 11桁になるまで+0
        if cnt == 1:
            while len(A[-1]) < 11:
                A[-1] += "0"
        # 12
        elif cnt == 2:
            while len(A[-1]) < 12:
                A[-1] += "0"
    else:
        A[-1] += ".000000000"
    tmp = ""
    for j in range(len(A[i])):
        if A[i][j] == '.':continue
        tmp += A[i][j]
    B.append(int(tmp))
    tmp = B[i]
    tmp2 = B[i]
    while tmp > 0:
        if tmp % 2 == 0:
            tmp //= 2
            C2[i] += 1
        else:
            break
    while tmp2 > 0:
        if tmp % 5 == 0:
            tmp //= 5
            C5[i] += 1
        else:
            break
Cc = [[0] * 19 for _ in range(19)]

for i in range(N):
    Cc[min(18, C2[i])][min(18, C5[i])]+=1

ans = 0
for i in range(N):
    l2 = max(0, 18 - C2[i])
    l5 = max(0, 18 - C5[i])
    for j in range(l2, 19):
        for k in range(l5, 19):
            ans += Cc[j][k]
for b in B:
    if b % 1000000000 == 0:
        ans -= 1
print(ans//2)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
import math


def div(n):
    n = int(n)
    two = format(n, 'b')[::-1].find('1')
    if two < 0:
        return(-1, -1)
    n = n >> two
    cnt = 0
    while n % 5 == 0:
        n //= 5
        cnt += 1
    return (two, cnt)


n = int(input())
arr = [float(input()) for _ in range(n)]
arr = [x for x in arr if min(x - int(x), math.ceil(x) - x) >= 0.000005 or x == int(x)]
arr = [div(x * 10**9) for x in arr]

ans = 0
for i in range(len(arr)):
    for j in range(i + 1, len(arr)):
        (a, b), (c, d) = arr[i], arr[j]
        if a + c >= 18 and b + d >= 18:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input(""))
a = []
n = 0
b = []

for i in range(N):
    A = float(input(""))
    a.append(A)

for i in range(N):
    for j in range(N):
        if i < j:
            try:
                S = int(a[i] * a[j])
                if S == (a[i] * a[j]):
                    n += 1
                    # b.append(S)

            except(ValueError):
                pass

# print(b)


print(n)

Submission status: Wrong Answer

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

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

    idx += 1
'''



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

    n = get_int()
    #youso2 = []
    #youso5 = []
    youso = []

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

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

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

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

            youso.append([count2, count5])
            #youso2.append(count2)
            #youso5.append(count5)

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

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

            #youso2.append(-len(s_d) + count2)

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

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

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

    youso.sort()
    #print(youso)

    ans = 0
    for i in range(0,n):
        y1 = youso[i]
        for ii in range(n-1, i, -1):
            y2 = youso[ii]
            if (y1[0] + y2[0] < 0):
                break

            if (y1[1] + y2[1] >= 0):
                ans += 1


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import pprint
N=int(input())
l2=[]
bit2=50
bit5=22
#table=[[0 for _ in range(20)] for _ in range(15)]
#table=[[0 for _ in range(45)] for _ in range(20)]
table=[[0 for _ in range(bit2)] for _ in range(bit5)]
for i in range(N):
    n=float(input())
    #print(n)
    n=int(n*pow(10,9))
    count2=0
    count5=0
    #print(n,kake)
    while n==2*(n//2):
        n=n//2
        count2=count2+1
    while n==5*(n//5):
        n=n//5
        count5=count5+1
    table[count5][count2]=table[count5][count2]+1
    l2.append([count2,count5])
#pprint.pprint(table)
#print(l2)
ans=0
for i in range(bit5):
    for j in range(bit2):
        num=table[i][j]
        min2=max(0,18-j)
        min5=max(0,18-i)
        cnt=0
        if num>0:
            #print(min2,min5,i,j,num)
            for k in range(min5,bit5):
                for l in range(min2,bit2):
                    cnt=cnt+table[k][l]
            if (min2<=j)and(min5<=i):
                cnt=cnt-1
            ans=ans+num*cnt
            #print(ans)
print(ans//2)

Submission status: Wrong Answer

Solution code:
import pprint
N=int(input())
l2=[]
bit2=50
bit5=22
#table=[[0 for _ in range(20)] for _ in range(15)]
#table=[[0 for _ in range(45)] for _ in range(20)]
table=[[0 for _ in range(bit2)] for _ in range(bit5)]
for i in range(N):
    n=float(input())
    #print(n)
    n=int(n*pow(10,9))
    count2=0
    count5=0
    #print(n,kake)
    while n==2*(n//2):
        n=n//2
        count2=count2+1
    while n==5*(n//5):
        n=n//5
        count5=count5+1
    table[count5][count2]=table[count5][count2]+1
    l2.append([count2,count5])
#pprint.pprint(table)
print(l2)
ans=0
for i in range(bit5):
    for j in range(bit2):
        num=table[i][j]
        min2=max(0,18-j)
        min5=max(0,18-i)
        cnt=0
        if num>0:
            #print(min2,min5,i,j,num)
            for k in range(min5,bit5):
                for l in range(min2,bit2):
                    cnt=cnt+table[k][l]
            if (min2<=j)and(min5<=i):
                cnt=cnt-1
            ans=ans+num*cnt
            #print(ans)
print(ans//2)

Submission status: Wrong Answer

Solution code:
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    counter = [[0] * 18 for _ in range(26)] # -9 ~ 13, -9 ~ 5
    ans = 0
    for _ in range(n):
        S = input()
        if '.' in S:
            a, b = S.split('.')
            two = five = -len(b)
            a = int(a + b)
        else:
            two = five = 0
            a = int(S)
        while a % 2 == 0:
            two += 1
            a //= 2
        while a % 5 == 0:
            five += 1
            a //= 5
        for i in range(-10, 15):
            for j in range(-10, 7):
                if two + i >= 0 and five + j >= 0:
                    ans += counter[i][j]
        counter[two][five] += 1
    print(ans)
resolve()

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=tf-8
#

"""
"""

from collections import defaultdict
import bisect

import sys
input = sys.stdin.readline
from decimal import *
from collections import Counter


def solve(n):
    cnt = Counter()
    n_int = 0
    for _ in range(n):
        getcontext().prec = 22
        a = input()
        da = Decimal(a)
        ia = int(da*(10**9))
        if ia%10**9 == 0:
            n_int += 1
        pmul_2 = 0
        pmul_5 = 0
        ia2 = ia
        while ((ia2 & 1) == 0 and pmul_2 < 18): 
            ia2 = ia2 >> 1
            pmul_2 += 1
        ia5 = ia
        while 1:
            if (ia5 % 5 ==0 and pmul_5 < 18):
                pmul_5 += 1
                ia5 = ia5//5
            else:
                break
        cnt[(pmul_2,pmul_5)] += 1
    ans = 0
    #print(cnt)
    for pm2_1 in range(0,19):
        for pm2_2 in range(18-pm2_1,19):
            for pm5_1 in range(1,19):
                for pm5_2 in range(18-pm5_1,19):
                    ans += cnt[(pm2_1,pm5_1)]*cnt[(pm2_2,pm5_2)]
    ans -= n_int
    ans = ans//2

    print(ans)
                






def main():
    n = int(input())
    solve(n)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
B = []
C2 = [0] * N
C5 = [0] * N
for i in range(N):
    s = str(input())
    A.append(s)
    ok = False
    cnt = 0
    l = len(A[-1])
    for j in range(l):
        if A[-1][j] == '.':
            ok = True
            cnt = j
    if ok:
        # 11桁になるまで+0
        if cnt == 1:
            while len(A[-1]) < 11:
                A[-1] += "0"
        # 12
        elif cnt == 2:
            while len(A[-1]) < 12:
                A[-1] += "0"
    else:
        A[-1] += ".000000000"
    tmp = ""
    for j in range(len(A[i])):
        if A[i][j] == '.':continue
        tmp += A[i][j]
    B.append(int(tmp))
    tmp = B[i]
    tmp2 = B[i]
    while tmp > 0:
        if tmp % 2 == 0:
            tmp //= 2
            C2[i] += 1
        else:
            break
    while tmp2 > 0:
        if tmp % 5 == 0:
            tmp //= 5
            C5[i] += 1
        else:
            break
Cc = [[] for _ in range(19)]
for i in range(N):
    Cc[min(18, C2[i])].append(C5[i])

for i in range(19):
    Cc[i].sort()
ans = 0
cnt99 = 0
for i in range(N):
    # 2がC2[i]個 -> 相手は最低18-C2[i]かつ、18 - C5[i]以上の個数
    M = 18 - C5[i]
    for j in range(max(0,18-C2[i]), 19):
        MM = M
        if C2[i] == 9 and C5[i] == 9 and j == 9:
            MM += 1
            cnt99+=1
        ok = -1
        ng = len(Cc[j])
        while abs(ok - ng) > 1:
            mid = (ok + ng) // 2
            if Cc[j][mid] >= MM:
                ok = mid
            else: ng = mid
        ans += ok+1
ans //= 2
ans += cnt99 * (cnt99 - 1) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal
n=int(input())
A=[float(input()) for _ in range(n)]
multiple=[Decimal(A[i-1]*A[i+j]) for i in range(1,n) for j in range(n-i) if float(Decimal(A[i-1]*A[i+j])).is_integer()]
print(len(multiple))

Submission status: Wrong Answer

Solution code:
from decimal import Decimal


def div(n):
    n = int(n)
    two = format(n, 'b')[::-1].find('1')
    if two < 0:
        return(-1, -1)
    n = n >> two
    cnt = 0
    while n % 5 == 0:
        n //= 5
        cnt += 1
    return (two, cnt)


n = int(input())
arr = [div(int(Decimal(input()) * 10**9)) for _ in range(n)]

ans = 0
for i in range(len(arr)):
    for j in range(i + 1, len(arr)):
        (a, b), (c, d) = arr[i], arr[i]
        if a + c >= 18 and b + d >= 18:
            ans += 1
    
print(ans)

Submission status: Wrong Answer

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=tf-8
#

"""
"""

from collections import defaultdict
import bisect

import sys
input = sys.stdin.readline
from decimal import *
from collections import Counter


def solve(n):
    cnt = Counter()
    n_int = 0
    for _ in range(n):
        getcontext().prec = 20
        a = input()
        da = Decimal(a)
        ia = int(da*(10**9))
        if ia%10**9 == 0:
            n_int += 1
        pmul_2 = 0
        pmul_5 = 0
        ia2 = ia
        while ((ia2 & 1) == 0 and pmul_2 < 18): 
            ia2 = ia2 >> 1
            pmul_2 += 1
        ia5 = ia
        while 1:
            if ia5 % 5 ==0:
                pmul_5 += 1
                ia5 = ia5//5
            else:
                break
        cnt[(pmul_2,pmul_5)] += 1
    ans = 0
    #print(cnt)
    for pm2_1 in range(0,19):
        for pm2_2 in range(18-pm2_1,19):
            for pm5_1 in range(1,19):
                for pm5_2 in range(18-pm5_1,19):
                    ans += cnt[(pm2_1,pm5_1)]*cnt[(pm2_2,pm5_2)]
    ans -= n_int
    ans = ans//2

    print(ans)
                






def main():
    n = int(input())
    solve(n)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

    idx += 1
'''



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

    n = get_int()
    #youso2 = []
    #youso5 = []
    youso = []

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

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

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

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

            youso.append([count2, count5])
            #youso2.append(count2)
            #youso5.append(count5)

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

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

            #youso2.append(-len(s_d) + count2)

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

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

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

    youso.sort()
    #print(youso)

    ans = 0
    for i in range(0,n):
        y1 = youso[i]
        for ii in range(n-1, i, -1):
            y2 = youso[ii]
            if (y1[0] + y2[0] < 0):
                break

            if (y1[0] + y2[0] >= 0) and (y1[1] + y2[1] >= 0):
                ans += 1


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

if __name__ == '__main__':
    main()