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
import math
import collections
import bisect
import itertools
import decimal

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
# MOD = 10 ** 9 + 7
MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===
def prime_factorize(n):
    two = 0
    five = 0
    while n % 2 == 0:
        two += 1
        n //= 2

    while n % 5 == 0:
        five += 1
        n //= 5

    return two, five


def main():
    n = ni()
    a = [int(float(input()) * (10 ** 9)) for _ in range(n)]
    res = {}
    border = 18

    twoflg = False
    fiveflg = False
    for ai in a:
        two, five = prime_factorize(ai)

        if two >= 9:
            twoflg = True
        if five >= 9:
            fiveflg = True

        if (two, five) not in res.keys():
            res[(two, five)] = 1
        else:
            res[(two, five)] += 1

    ans = 0
    if twoflg and fiveflg:
        for k, v in res.items():
            two, five = k
            for tk, tv in res.items():
                t_two, t_five = tk
                if two + t_two >= border and five + t_five >= border:
                    if two == t_two and five == t_five:
                        ans += v * (tv - 1)
                    else:
                        ans += v * tv

    print(ans // 2)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import bisect
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
# MOD = 10 ** 9 + 7
MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))


# ===CODE===
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    n = ni()
    a = [int(float(input()) * (10 ** 9)) for _ in range(n)]
    res = {}
    border = 18

    for ai in a:
        tmp = prime_factorize(ai)
        c = collections.Counter(tmp)
        two = 0
        five = 0
        if 2 in c.keys():
            two = c[2]
        if 5 in c.keys():
            five = c[5]

        if (two, five) not in res.keys():
            res[(two, five)] = 1
        else:
            res[(two, five)] += 1

    ans = 0
    for k, v in res.items():
        two, five = k
        for tk, tv in res.items():
            t_two, t_five = tk
            if two + t_two >= border and five + t_five >= border:
                if two == t_two and five == t_five:
                    ans += v * (tv - 1)
                else:
                    ans += v * tv

    print(ans // 2)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = 0
ls = []
for i in range(n):
  l = float(input())
  ls = ls + [l]

for i in range(n):
  for j in range(n):
    if i >= j:
      continue
    if ((ls[i])*(ls[j]))%1 == 0:
      ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
def div_count(x,d):
    res = 0
    while x:
        if x%d == 0:
            x //= d
            res += 1
        else:
            break
    return res

# t = [i for i in range(37)]
# for tt in t:
#     print("tt:",tt)
#     print("2:",div_count(tt,2))
#     print("5:",div_count(tt,5))
#     print("=======")

n = int(input())
a = []
for i in range(n):
    ai = float(input())
    ai *= 10**9
    a.append(ai)
from collections import Counter
c1 = Counter()
c2 = Counter()
b = []
for ai in a:
    two = div_count(ai,2)
    five = div_count(ai,5)
    c1[(two,five)] += 1
#     c2[(two,five)] += 1
#     b.append((two,five))
# print(b)

e = []
for k1,v1 in c1.items():
    tw1,fi1 = k1
    e.append((tw1,fi1,v1))
ans = 0
for i,ei in enumerate(e):
    for j,ej in enumerate(e):
        ti,fi,vi = ei
        tj,fj,vj = ej
        if j < i:
            continue
        elif i == j:
            if ti+tj >= 18 and fi+fj >= 18:
                ans += vi*(vi-1)//2
        else:
            if ti+tj >= 18 and fi+fj >= 18:
                ans += vi*vj

print(ans)

Submission status: Wrong Answer

Solution code:

import sys
input = sys.stdin.readline

def inp():
    return(int(input()))

def inpf():
    return(float(input()))

n = inp()
an = []
for i in range(n):
    an.append(inpf())

cnt = 0 
for i in range(n-1):
        for j in range(i+1,n):
            if an[i]*an[j] == round(an[i]*an[j]):
                cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
"""
小数の状態だと処理しづらいので、与えられた数を全て10**9倍して小数を確実になくした上で
問題文を下記のように言い換える。
「積が10**18の倍数になるような数の組み合わせの数がいくつあるか」
数Aiがあり、Aiの2の素因数の数がn, 5の素因数の数がmのとき、
数Ai自体ですでにmin(n,m)個の0の数を持っている。この場合、のこり必要な0の数はx = 18-min(n,m)個である。
ここで、n == mの場合：
Aiの相方は少なくとも2,5の素因数をそれぞれx個以上持っていなくてはならない。
n > mの場合：
Aiの相方は少なくとも2の素因数をx-(n-m)個、5の素因数をx個持っていなくてはいけない。

m > nの場合：
Aiの相方は少なくとも2の素因数をx個以上、5の素因数をx-(m-n)個以上持っていなくてはならない。
"""
N = int(input())
dp = [[0]*(19) for _ in range(19)]
ans = 0
for _ in range(N):
    a = round(float(input())*pow(10,9))
    two = 0
    while a % 2 == 0:
        a //= 2
        two += 1
    five = 0
    while a % 5 == 0:
        a //= 5
        five += 1

    ans += dp[18-two][18-five]
    for i in range(min(two+1,19)):
        for j in range(min(five+1,19)):
            dp[i][j] += 1
print(ans)

Submission status: Wrong Answer

Solution code:
"""
小数の状態だと処理しづらいので、与えられた数を全て10**9倍して小数を確実になくした上で
問題文を下記のように言い換える。
「積が10**18の倍数になるような数の組み合わせの数がいくつあるか」
数Aiがあり、Aiの2の素因数の数がn, 5の素因数の数がmのとき、
数Ai自体ですでにmin(n,m)個の0の数を持っている。この場合、のこり必要な0の数はx = 18-min(n,m)個である。
ここで、n == mの場合：
Aiの相方は少なくとも2,5の素因数をそれぞれx個以上持っていなくてはならない。
n > mの場合：
Aiの相方は少なくとも2の素因数をx-(n-m)個、5の素因数をx個持っていなくてはいけない。

m > nの場合：
Aiの相方は少なくとも2の素因数をx個以上、5の素因数をx-(m-n)個以上持っていなくてはならない。
"""
N = int(input())
dp = [[0]*(19) for _ in range(19)]
ans = 0
for _ in range(N):
    a = float(input())
    a *= 10**9
    two = 0
    while a % 2 == 0:
        a //= 2
        two += 1
    five = 0
    while a % 5 == 0:
        a //= 5
        five += 1

    ans += dp[18-two][18-five]
    for i in range(min(two+1,19)):
        for j in range(min(five+1,19)):
            dp[i][j] += 1
print(ans)

Submission status: Wrong Answer

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

N = int(readline())
A = [float(readline()) * (10 ** 9) for i in range(N)]

# 素因数分解して、2と5が何回現れるかをカウントする
# C[i][j] = 2がi回、5がj回現れる数。0～18なので19個でOK
C = [[0] * 19 for i in range(19)]

for a in A:
  cnt2 = 0
  cnt5 = 0
  while a % 2 == 0:
    cnt2 += 1 
    a //= 2
  while a % 5 == 0:
    cnt5 += 1
    a //= 5
  C[min(cnt2, 18)][min(cnt5, 18)] += 1

# 2の倍数と5の倍数の数がどちらも18以上になるペアを探索する

ans = 0
# まず、2の倍数と5の倍数の数が同じもの同士でペアを作れるかを探索する
for i in range(19):
  for j in range(19):
    if i * 2 >= 18 and j * 2 >= 18:
      n = C[i][j]
      ans += (n * (n - 1)) // 2

# 次に、2の倍数と5の倍数の数が異なるもの同士でペアを探索する
# 並び替えて同じになるもの、例えば(9,10) & (15,14)のペアと(15,14) & (9,10)を重複して数えないように注意する

diff_pair = 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:
          diff_pair += C[i][j] * C[p][q]
          
diff_pair //= 2

ans += diff_pair

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from itertools import chain

readline = sys.stdin.readline
class Bit:
    def __init__(self, lst):
        t = 1
        while (t << 1) <= len(lst):
            for i in range(t, len(lst) - t + 1, t << 1):
                lst[i + t - 1] += lst[i - 1]
            t <<= 1
        self.lst = lst

    def add(self, pos, value):
        pos += 1
        while pos <= len(self.lst):
            self.lst[pos - 1] += value
            pos += pos & (-pos)

    def update(self, pos, value):
        diff = value - self.at(pos)
        self.add(pos, diff)

    def at(self, pos):
        return self.sum(pos + 1) - self.sum(pos)
    
    def sum(self, pos):
        # sum of [0, pos)
        if pos == 0:
            return 0
        s = 0
        while pos > 0:
            s += self.lst[pos - 1]
            #pos -= pos & (-pos)
            pos &= ~(-pos)
        return s
    
def solve():
    N = int(readline())
    A = [float(readline()) for i in range(N)]

    C = [0] * N
    c5s = set()

    for i, a in enumerate(A):
        b = int(a * (10 ** 10))
        #b = a * (10 ** 10)
        c2, c5 = -10, -10
        while b % 2 == 0:
            b //= 2
            c2 += 1
        while b % 5 == 0:
            b //= 5
            c5 += 1
        
        C[i] = (c2, c5)
    
    Q = [(-a, -b) for a,b in C]

    count0 = sum(a >= 0 and b >= 0 for a,b in C)

    # Coordinate compression
    xs = sorted(set(chain((a for a,b in C), (a for a,b in Q))))
    ys = sorted(set(chain((b for a,b in C), (b for a,b in Q))))
    compA = {v: i for i, v in enumerate(xs)}
    compB = {v: i for i, v in enumerate(ys)}
    C = [(compA[a], compB[b]) for a,b in C]
    Q = [(compA[a], compB[b]) for a,b in Q]
    H, W = len(xs), len(ys)

    C.sort()
    Q.sort(reverse=True)

    bit = Bit([0] * W)
    ans = 0

    j = N - 1
    for x, y in Q:
        while j >= 0 and C[j][0] >= x:
            bit.add(C[j][1], 1)
            j -= 1
        ans += bit.sum(W) - bit.sum(y)

    print((ans - count0) // 2)


solve()

Submission status: Wrong Answer

Solution code:
import sys
from itertools import chain

readline = sys.stdin.readline
class Bit:
    def __init__(self, lst):
        t = 1
        while (t << 1) <= len(lst):
            for i in range(t, len(lst) - t + 1, t << 1):
                lst[i + t - 1] += lst[i - 1]
            t <<= 1
        self.lst = lst

    def add(self, pos, value):
        pos += 1
        while pos <= len(self.lst):
            self.lst[pos - 1] += value
            pos += pos & (-pos)

    def update(self, pos, value):
        diff = value - self.at(pos)
        self.add(pos, diff)

    def at(self, pos):
        return self.sum(pos + 1) - self.sum(pos)
    
    def sum(self, pos):
        # sum of [0, pos)
        if pos == 0:
            return 0
        s = 0
        while pos > 0:
            s += self.lst[pos - 1]
            #pos -= pos & (-pos)
            pos &= ~(-pos)
        return s
    
def solve():
    N = int(readline())
    A = [float(readline()) for i in range(N)]

    C = [0] * N
    c5s = set()

    for i, a in enumerate(A):
        b = a * (10 ** 10)
        c2, c5 = -10, -10
        while b % 2 == 0:
            b //= 2
            c2 += 1
        
        while b % 5 == 0:
            b //= 5
            c5 += 1
        
        C[i] = (c2, c5)
    
    Q = [(-a, -b) for a,b in C]

    count0 = sum(a >= 0 and b >= 0 for a,b in C)

    # Coordinate compression
    xs = sorted(set(chain((a for a,b in C), (a for a,b in Q))))
    ys = sorted(set(chain((b for a,b in C), (b for a,b in Q))))
    compA = {v: i for i, v in enumerate(xs)}
    compB = {v: i for i, v in enumerate(ys)}
    C = [(compA[a], compB[b]) for a,b in C]
    Q = [(compA[a], compB[b]) for a,b in Q]
    H, W = len(xs), len(ys)

    C.sort()
    Q.sort(reverse=True)

    bit = Bit([0] * W)
    ans = 0

    j = N - 1
    for x, y in Q:
        while j >= 0 and C[j][0] >= x:
            bit.add(C[j][1], 1)
            j -= 1
        ans += bit.sum(W) - bit.sum(y)

    print((ans - count0) // 2)


solve()

Submission status: Wrong Answer

Solution code:
import sys
from itertools import chain

readline = sys.stdin.readline
class Bit:
    def __init__(self, lst):
        t = 1
        while (t << 1) <= len(lst):
            for i in range(t, len(lst) - t + 1, t << 1):
                lst[i + t - 1] += lst[i - 1]
            t <<= 1
        self.lst = lst

    def add(self, pos, value):
        pos += 1
        while pos <= len(self.lst):
            self.lst[pos - 1] += value
            pos += pos & (-pos)

    def update(self, pos, value):
        diff = value - self.at(pos)
        self.add(pos, diff)

    def at(self, pos):
        return self.sum(pos + 1) - self.sum(pos)
    
    def sum(self, pos):
        # sum of [0, pos)
        if pos == 0:
            return 0
        s = 0
        while pos > 0:
            s += self.lst[pos - 1]
            #pos -= pos & (-pos)
            pos &= ~(-pos)
        return s
    
def solve():
    N = int(readline())
    A = [float(readline()) for i in range(N)]

    C = [0] * N
    c5s = set()

    for i, a in enumerate(A):
        b = a * (10 ** 10)
        c2, c5 = -10, -10
        while b % 2 == 0:
            b //= 2
            c2 += 1
        
        while b % 5 == 0:
            b //= 5
            c5 += 1
        
        C[i] = (c2, c5)
    
    Q = [(-a, -b) for a,b in C]

    count0 = sum(a == 0 and b == 0 for a,b in C)

    # Coordinate compression
    xs = sorted(set(chain((a for a,b in C), (a for a,b in Q))))
    ys = sorted(set(chain((b for a,b in C), (b for a,b in Q))))
    compA = {v: i for i, v in enumerate(xs)}
    compB = {v: i for i, v in enumerate(ys)}
    C = [(compA[a], compB[b]) for a,b in C]
    Q = [(compA[a], compB[b]) for a,b in Q]
    H, W = len(xs), len(ys)

    C.sort()
    Q.sort(reverse=True)

    bit = Bit([0] * W)
    ans = 0

    j = N - 1
    for x, y in Q:
        while j >= 0 and C[j][0] >= x:
            bit.add(C[j][1], 1)
            j -= 1
        ans += bit.sum(W) - bit.sum(y)
    

    print(ans // 2 - count0)


solve()

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

A = []
for i in range(N):
    num = float(input()) * 1000000000
    A.append(int(num))


def count2(n):
    ret = 0
    while(n % 2 == 0):
        ret += 1
        n /= 2
    return ret


def count5(n):
    ret = 0
    while(n % 5 == 0):
        ret += 1
        n /= 5
    return ret


table = {}
for i in range(19):
    for j in range(19):
        table[i, j] = 0

for a in A:
    c2 = count2(a)
    c5 = count5(a)
    if(c2 > 18):
        c2 = 18
    if(c5 > 18):
        c5 = 18
    table[c2, c5] += 1

res = 0
for i in range(19):
    for j in range(19):
        for k in range(19):
            for l in range(19):
                if i + k >= 18 and j + l >= 18:
                    if i == k and j == l:
                        res += table[i, j] * (table[i, j] - 1)
                    else:
                        res += table[i, j] * table[k, l]

print(res // 2)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

A = []
for i in range(N):
    num = float(input()) * 1000000000
    A.append(int(num))


def count2(n):
    ret = 0
    while(n % 2 == 0):
        ret += 1
        n /= 2
    return ret


def count5(n):
    ret = 0
    while(n % 5 == 0):
        ret += 1
        n /= 5
    return ret


table = {}
for i in range(19):
    for j in range(19):
        table[i, j] = 0

for a in A:
    c2 = count2(a)
    c5 = count5(a)
    if(c2 > 18):
        c2 = 18
    if(c5 > 18):
        c5 = 18
    table[c2, c5] += 1

res = 0
for a in A:
    pair = count2(a), count5(a)
    t, f = pair
    if t > 18:
        t = 18
    if f > 18:
        f = 18
    for i in range(18 - t, 19):
        for j in range(18 - f, 19):
            res += table[i, j]
    if t >= 9 and f >= 9:
        res -= 1

print(res // 2)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

A = []
for i in range(N):
    num = float(input()) * 10000
    if float.is_integer(num):
        A.append(int(num))


def count2(n):
    ret = 0
    while(n % 2 == 0):
        ret += 1
        n /= 2
    return ret


def count5(n):
    ret = 0
    while(n % 5 == 0):
        ret += 1
        n /= 5
    return ret


table = {}
for i in range(9):
    for j in range(9):
        table[i, j] = 0

for a in A:
    c2 = count2(a)
    c5 = count5(a)
    if(c2 > 8):
        c2 = 8
    if(c5 > 8):
        c5 = 8
    for i in range(c2 + 1):
        for j in range(c5 + 1):
            table[i, j] += 1

res = 0
for a in A:
    pair = count2(a), count5(a)
    t, f = pair
    if t > 8:
        t = 8
    if f > 8:
        f = 8
    res += table[8 - t, 8 - f]
    if t >= 4 and f >= 4:
        res -= 1

print(res // 2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

s=0   
for i in range(n):
    if A[i]==int(A[i]):
        for j in range(i+1,n):
            if A[j]==int(A[j]):
                s+=1
            elif A[j]*A[i]==int(A[j]*A[i]):
                s+=1
    else :
        for j in range(i+1,n):
            if A[j]*A[i]==int(A[j]*A[i]):
                s+=1
    
print(s)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
#QN = map(int,input().split()) # 500
N = int(input())

list = []
for i in range(N):
  list.append(float(input()))

no = 1
cnt =0
for i in range(N):
  for j in range(N-no):
    res = list[i] * list[no+j]
    if (res.is_integer()):
      cnt += 1
  no += 1

print("{}".format(cnt))

Submission status: Wrong Answer

Solution code:
1

Submission status: Wrong Answer

Solution code:
i = lst = [] 
inc=0
  
# number of elemetns as input 
n = int(input()) 
  
# iterating till the range 
for i in range(0, n): 
    ele = float(input()) 
  
    lst.append(ele) # adding the element 
      
#print(lst) 
for i in range (0,n):
   a = lst[i]
   for i in range (i+1,n):
     b = lst[i] * a * 10
     if b % 10 == 0:
       #print("tarue")
       inc+=1
print(inc)
     #else:
      # print("faa")

Submission status: Wrong Answer

Solution code:
kosuu = int(input())
lis_lis = [0]*kosuu
tt = [0]*200000
count = 0

for i in range(kosuu):
    lis_lis[i]=input()

for i in range(kosuu):
    for j in range(kosuu -i -1):
        a = float(lis_lis[i]) * float(lis_lis[kosuu-j-1])
        if True == a.is_integer():
            if a not in tt:
                tt.append(a)
                count += 1
print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())
ss=[input() for i in range(N)]
b=int()
for j in range(N-1):
    #print(int(N/2))
    for i in range(j+1,N):
        a=float(ss[j])*float(ss[i])
        if a.is_integer()==True:
            b+=1
        else:
            b+=0
print(b)

Submission status: Wrong Answer

Solution code:
N=int(input())
ss=[input() for i in range(N)]
b=int()
for i in range(N):
    for j in range(int(N/2)):
        a=float(ss[j])*float(ss[i])
        if a.is_integer()==True:
            b+=1
print(b)

Submission status: Wrong Answer

Solution code:
n = int(input())
dic = {}
for i in range(45):
  for j in range(20):
    dic[(i, j)] = 0
for _ in range(n):
  a = float(input())
  a *= 10**9
  a = int(a)
  idx_2 = 0
  while a % 2 == 0:
    a //= 2
    idx_2 += 1
  idx_5 = 0
  while a % 5 == 0:
    a //= 5
    idx_5 += 1
  dic[(idx_2, idx_5)] += 1

lst = []
for k, v in dic.items():
  lst.append([k[0], k[1], v])

cnt = 0
for i in range(len(lst)):
  a, b, c = lst[i][0], lst[i][1], lst[i][2]
  for j in range(i, len(lst)):
    d, e, f = lst[j][0], lst[j][1], lst[j][2]
    if a + a >= 18 and b + b >= 18 and j == i:
      cnt += (c * (c - 1)) // 2
    elif a + d >= 18 and b + e >= 18 and j > i:
      cnt += c * f
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
dic = {}
for i in range(45):
  for j in range(20):
    dic[(i, j)] = 0
for _ in range(n):
  a = float(input())
  a *= 10**9
  idx_2 = 0
  while a % 2 == 0:
    a //= 2
    idx_2 += 1
  idx_5 = 0
  while a % 5 == 0:
    a //= 5
    idx_5 += 1
  dic[(idx_2, idx_5)] += 1

lst = []
for k, v in dic.items():
  lst.append([k[0], k[1], v])

cnt = 0
for i in range(len(lst)):
  a, b, c = lst[i][0], lst[i][1], lst[i][2]
  for j in range(i, len(lst)):
    d, e, f = lst[j][0], lst[j][1], lst[j][2]
    if a + a >= 18 and b + b >= 18 and j == i:
      cnt += (c * (c - 1)) // 2
    elif a + d >= 18 and b + e >= 18 and j > i:
      cnt += c * f
print(cnt)

Submission status: Wrong Answer

Solution code:
import copy
n = int(input())
def point_shift(s,i):#文字列型の小数を正確に10**iかけて整数にする
    p = s.index(".")
    tale = len(s[p+1:])
    if tale <= i:
        return int(s[:p]+s[p+1:].ljust(i,"0"))
    else:
        return int(s[:p]+s[p+1:p+i+1])

a = []
for i in range(n):
    s = input()
    if "." not in s:
        a.append(int(s)*10**9)
    else:
        a.append(point_shift(s,9))

memo = [[0,0] for _ in range(n)]
for i in range(n):
    t = a[i]
    while t%2 == 0:
        t //= 2
        memo[i][0] += 1
    while t%5 == 0:
        t //= 5
        memo[i][1] += 1

l0 = [[0]*100 for _  in range(100)]
for i in range(n):
    l0[memo[i][0]][memo[i][1]] += 1

l1 = copy.deepcopy(l0)
for i in range(100):
    for j in range(98,-1,-1):
        l1[i][j] += l1[i][j+1]
for i in range(98,-1,-1):
    for j in range(100):
        l1[i][j] += l1[i+1][j]

ans = 0
for i in range(100):
    for j in range(100):
        x0,y0 = i,j
        x1,y1 = 18-x0,18-y0
        if x0 >= 9 and y0 >= 9:
            ans += l0[x0][y0]*(l1[x1][y1]-1)
        else:
            ans += l0[x0][y0]*l1[x1][y1]
print(ans//2)

Submission status: Wrong Answer

Solution code:
n = int(input())
dic = {}
for i in range(45):
  for j in range(20):
    dic[(i, j)] = 0
for _ in range(n):
  a = float(input())
  a *= 10**9
  idx_2 = 0
  while a % 2 == 0:
    a //= 2
    idx_2 += 1
  idx_5 = 0
  while a % 5 == 0:
    a //= 5
    idx_5 += 1
  dic[(idx_2, idx_5)] += 1

lst = []
for k, v in dic.items():
  lst.append([k[0], k[1], v])

cnt = 0
for i in range(len(lst)):
  for j in range(i, len(lst)):
    a, b, c = lst[i][0], lst[i][1], lst[i][2]
    d, e, f = lst[j][0], lst[j][1], lst[j][2]
    if a + d >= 18 and b + e >= 18 and j == i:
      cnt += (c * (c - 1)) // 2
    elif a + d >= 18 and b + e >= 18:
      cnt += c * f
print(cnt)

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def is_ok(arg):
    return a[i][j]+a[arg][j] >= 0

def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

n = INT()
a = [[0]*19 for i in range(19)]
for i in range(n):
    A = int(float(input())*10**9)
    m2 = m5 = 0
    while A % 2 == 0:
        A //= 2
        m2 += 1
    while A % 5 == 0:
        A //= 5
        m5 += 1
    m2 = min(m2, 18)
    m5 = min(m5, 18)
    a[m2][m5] += 1

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

Submission status: Wrong Answer

Solution code:
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

def is_ok(arg):
    return a[i][j]+a[arg][j] >= 0

def meguru_bisect(ng, ok):
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok

n = INT()
a = defaultdict(int)
for i in range(n):
    A = int(float(input())*10**9)
    m2 = m5 = 0
    while A % 10 == 0:
        A //= 10
        m2 += 1
        m5 += 1
    while A % 2 == 0:
        A //= 2
        m2 += 1
    while A % 5 == 0:
        A //= 5
        m5 += 1
    a[(m2, m5)] += 1

ans = 0
c0 = 0
for k0, v0 in a.items():
    c0 += 1
    c1 = 0
    for k1, v1 in a.items():
        c1 += 1
        if k0[0]+k1[0] >= 18 and k0[1]+k1[1] >= 18:
            if c0 < c1:
                ans += v0 * v1
            elif c0 == c1:
                ans += v0 * ( v0 - 1 ) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
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

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

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

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = I()
A = []
dic = DD(int)
for _ in range(N):
  s = S().split(".")
  if len(s) == 1:
    temp = int(s[0])*(10**9)
  else:
    temp = int(s[0])*(10**9)+int(s[1])*(10**(9-len(s[1])))
  _2,_5 = 0,0
  for p,n in factorization(temp):
    if p==2:_2 = min(n,18)
    if p==5:_5 = min(n,18)
  dic[(_2,_5)] += 1
exit()
ans1 = 0
ans2 = 0
for i2 in range(19):
  for j2 in range(18-i2,19):
    for i5 in range(19):
      for j5 in range(18-i5,19):
        if (i2,i5)==(j2,j5):
          ans1 += dic[(i2,i5)]*(dic[(j2,j5)]-1)
        else:
          ans2 += dic[(i2,i5)]*dic[(j2,j5)]

print((ans1+ans2)//2)