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:
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
            else:
                ans += v0 * ( v0 - 1 ) // 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 = [[0]*40 for i in range(40)]
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
for i in range(40):
    for j in range(40):
        if a[i][j] > 0:
            for k in range(40):
                for l in range(40):
                    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 = [[0]*25 for i in range(25)]
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
    try:
        a[m2][m5] += 1
    except:
        continue

ans = 0
for i in range(25):
    for j in range(25):
        if a[i][j] > 0:
            for k in range(25):
                for l in range(25):
                    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 = []
for i in range(n):
    A = int(float(input())*10**9)
    m2 = m5 = -9
    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.append([m2, m5])
a.sort()

ans = 0
for i in range(n):
    j = 0
    tmp = meguru_bisect(i, n)
    if tmp < n:
        j = 1
        ans += n - meguru_bisect(max(i, tmp-1), n)
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 = []
for i in range(n):
    A = int(float(input())*10**9)
    m2 = m5 = -9
    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.append([m2, m5])
a.sort()

ans = 0
for i in range(n):
    j = 0
    tmp = meguru_bisect(i, n)
    if tmp < n:
        j = 1
        ans += n - meguru_bisect(min(i, tmp-1), n)
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [float(input()) for _ in range(N)]
for i in range(N):  A[i] *= 10 ** 9
  
c = [[0 for _ in range(19)] for _ in range(19)]

for i in range(N):
    p = A[i]
    cnt2 = 0
    while(not p % 2):
        p /= 2
        cnt2 += 1

    p = A[i]
    cnt5 = 0
    while(not p % 5):
        p /= 5
        cnt5 += 1
        
    c[min(cnt2, 18)][min(cnt5, 18)] += 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 and c[i][j]:  ans += (c[i][j] * (c[i][j] - 1))
                    else:  ans += c[i][j] * c[k][l]
print(ans // 2)

Submission status: Wrong Answer

Solution code:
N = int(input())
numlist = [0] * (N + 1)
log2 = [0] * (N + 1)
log5 = [0] * (N + 1)
acc = [[0 for i in range(19)] for j in range(19)]
Ans = 0

for i in range(1,N+1):
  numlist[i] = float(input()) * 1000000000

  wk = numlist[i]
  for cnt in range(1,19):
    if wk % 2 == 0:
      log2[i] += 1
      wk = wk // 2
    else:
      break

  for cnt in range(1,19):
    if wk % 5 == 0:
      log5[i] += 1
      wk = wk // 5
    else:
      break

  acc[log2[i]][log5[i]] += 1
    
for i in range(0,19):
  for j in range(0,19): 
    for k in range(0,19):
      for l in range(0,19):
        if (i + k) >=18 and (j + l) >= 18 and (i < k or (i == k and j <= l)):
          if acc[i][j] > 0 and acc[k][l] > 0:
            Ans += acc[i][j] * acc[k][l]
            if i >= 9 and j >= 9 and i == k and j == l:
              Ans -= int((acc[i][j] * (acc[i][j] + 1)) / 2)

print(Ans)

Submission status: Wrong Answer

Solution code:
t=int(input())
l=[]
c=0
for _ in range(t):
	a=float(input())
	l.append(a)
for i in range(t):
	for j in range(i+1,t):
		if l[i]*l[j]==int(l[i]*l[j]):
			c+=1
print(c)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [float(input()) for _ in range(N)]
cnt = 0
for n1, i in enumerate(A):
  for n2, j in enumerate(A[n1+1:], 1):
    if n1 == n2:
      continue
    k = i * j
    cnt += k == int(k)
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
numlist = [0] * (N + 1)
log2 = [0] * (N + 1)
log5 = [0] * (N + 1)
acc = [[0 for i in range(19)] for j in range(19)]
Ans = 0

for i in range(1,N+1):
  numlist[i] = float(input()) * 1000000000

  wk = numlist[i]
  for cnt in range(1,19):
    if wk % 2 == 0:
      log2[i] += 1
      wk = wk // 2
    else:
      break

  for cnt in range(1,19):
    if wk % 5 == 0:
      log5[i] += 1
      wk = wk // 5
    else:
      break

  acc[log2[i]][log5[i]] += 1
    
for i in range(0,19):
  for j in range(0,19): 
    for k in range(i,19):
      for l in range(0,19):
        if (i + k) >=18 and (j + l) >= 18 and (i < k or (i == k and j <= l)):
          if acc[i][j] > 0 and acc[k][l] > 0:
            Ans += acc[i][j] * acc[k][l]
            #print("+:" + str(acc[i][j] * acc[k][l]))
            if i >= 9 and j >= 9 and i == k and j == l:
              Ans -= (acc[i][j] * (acc[i][j] + 1)) / 2
              #print("-:" + str(acc[i][j]))

print(int(Ans))
#print(acc)

Submission status: Wrong Answer

Solution code:
N=int(input())
list1=[]
cnt=0
for i in range(N):
  list1.append(float(input()))
for i in range(N):
  for j in range(N-i-1):
    if isinstance(((list1[i])*(list1[j])),int):
      cnt=cnt+1
print(cnt)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import itertools
from functools import reduce

def load():
    num = int(input())
    numbers = [float(input()) for _ in range(num)]

    return numbers


if __name__ == "__main__":
    numbers = load()
    counter = sum(filter(lambda _: _, map(lambda n: float.is_integer(n[0] * n[1]), itertools.combinations(numbers, 2))))
    print(counter)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import itertools
from functools import reduce

def is_integer(number):
    # return float.is_integer(number)
    if float.is_integer(number):
        return 1
    return 0

def load():
    num = int(input())
    numbers = [float(input()) for _ in range(num)]

    return numbers


if __name__ == "__main__":
    numbers = load()
    counter = reduce(lambda a, b: a + is_integer(b[0] * b[1]), itertools.combinations(numbers, 2), 0)
    print(counter)

Submission status: Wrong Answer

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

def is_integer(number):
    # return float.is_integer(number)
    if float.is_integer(number):
        return 1
    return 0

def load():
    num = int(input())
    numbers = [float(input()) for _ in range(num)]

    return numbers


if __name__ == "__main__":
    numbers = load()
    counter = [is_integer(A_i * A_j) for A_i, A_j in itertools.combinations(numbers, 2)]
    print(sum(counter))

Submission status: Wrong Answer

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

def is_integer(number):
    # return float.is_integer(number)
    if float.is_integer(number):
        return 1
    return 0

def load():
    num = int(input())
    numbers = [float(input()) for _ in range(num)]

    return numbers


if __name__ == "__main__":
    numbers = load()
    counter = [is_integer(A_i * A_j) for A_i, A_j in itertools.permutations(numbers, 2)]
    print(sum(counter))

Submission status: Wrong Answer

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

def is_integer(number):
    # return float.is_integer(number)
    if float.is_integer(number):
        return 1
    return 0

def load():
    num = int(input())
    numbers = [float(input()) for _ in range(num)]

    return numbers


def get_pair(numbers):
    num = len(numbers)

    for i in range(num - 1):
        for j in range(i + 1, num):
            yield (numbers[i], numbers[j])


if __name__ == "__main__":
    numbers = load()
    counter = [is_integer(A_i * A_j) for A_i, A_j in get_pair(numbers)]

    print(sum(counter))

Submission status: Wrong Answer

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

def is_integer(number):
    return float.is_integer(number)


def load():
    num = int(input())
    numbers = [float(input()) for _ in range(num)]

    return numbers


def get_pair(numbers):
    num = len(numbers)

    for i in range(num - 1):
        for j in range(i + 1, num):
            yield (numbers[i], numbers[j])


if __name__ == "__main__":
    numbers = load()
    counter = 0

    for A_i, A_j in get_pair(numbers):
        prod = A_i * A_j
        if is_integer(prod):
            counter += 1

    print(counter)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def dev(a):
    d = {}
    for i in (2, 5):
        r = 0
        while a % i == 0:
            r += 1
            a //= i
        d[i] = min(18, r)
    return d


def main():
    N = int(input())
    A = []
    for _ in range(N):
        s = input().strip().split(".")
        a = int(s[0]) * (10 ** 9)
        if len(s) > 1:
            a += int(float("0." + s[1]) * (10 ** 9))
        # a = int(float(input()) * (10 ** 9))
        # print(a)
        A.append(dev(a))
    # print(A)
    S = [[0] * 19 for _ in range(19)]
    dp = [[0] * 20 for _ in range(20)]
    for a in A:
        S[a[2]][a[5]] += 1

    # print(S)
    for i in range(19):
        for j in range(19):
            dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1] - dp[i][j] + S[i][j]
    
    # print(dp[-1])
    res = 0
    for a in A:
        s = 18 - a[2]
        t = 18 - a[5]
        
        r = N - dp[-1][t] - dp[s][-1] + dp[s][t]
        if a[2] >= 9 and a[5] >= 9:
            r -= 1
        # print(a, r)
        res += r
    print(res // 2)
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def dev(a):
    d = {}
    for i in (2, 5):
        r = 0
        while a % i == 0:
            r += 1
            a //= i
        d[i] = min(18, r)
    return d


def main():
    N = int(input())
    A = []
    for _ in range(N):
        s = input().strip().split(".")
        a = int(s[0]) * (10 ** 9)
        if len(s) > 1:
            a += int(float("0." + s[1]) * (10 ** 9))
        # a = int(float(input()) * (10 ** 9))
        print(a)
        A.append(dev(a))
    # print(A)
    S = [[0] * 19 for _ in range(19)]
    dp = [[0] * 20 for _ in range(20)]
    for a in A:
        S[a[2]][a[5]] += 1

    # print(S)
    for i in range(19):
        for j in range(19):
            dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1] - dp[i][j] + S[i][j]
    
    # print(dp[-1])
    res = 0
    for a in A:
        s = 18 - a[2]
        t = 18 - a[5]
        
        r = N - dp[-1][t] - dp[s][-1] + dp[s][t]
        if a[2] >= 9 and a[5] >= 9:
            r -= 1
        # print(a, r)
        res += r
    print(res // 2)
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [(input()) for _ in range(n)]
new_a = [int(float(i)*(10**9)) for i in a]
table = list( [0 for _ in range(19)] for _ in range(19))

def ten(n):
    count2 = 0
    count5 = 0
    while n%2==0:
        count2 += 1
        n //= 2
    while n%5==0:
        count5 += 1
        n //= 5
    count2 = min(count2, 18)
    count5 = min(count5, 18)
    table[count2][count5] += 1
for i in new_a:
    ten(i)

ans = 0
for i in range(19):
    for j in range(19):
        a = table[i][j]
        for k in range(max(18-i,i),19):
            for u in range(max(18-j,j),19):
                b = table[k][u]
                ans += a*b
                if i==k and j==u:
                  ans -= a
ans //= 2

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [(input()) for _ in range(n)]
new_a = [int(float(i)*(10**9)) for i in a]
table = list( [0 for _ in range(19)] for _ in range(19))

def ten(n):
    count2 = 0
    count5 = 0
    while n%2==0:
        count2 += 1
        n //= 2
    while n%5==0:
        count5 += 1
        n //= 5
    count2 = min(count2, 18)
    count5 = min(count5, 18)
    table[count2][count5] += 1
for i in new_a:
    ten(i)

ans = 0
for i in range(19):
    for j in range(19):
        a = table[i][j]
        for k in range(18-i,19):
            for u in range(18-j,19):
                b = table[k][u]
                ans += a*b
                if 9<=i and 9<=j and i==k and j==u:
                  ans -= a

                  
ans //= 2
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [(input()) for _ in range(n)]
new_a = [int(float(i)*(10**9)) for i in a]
table = list( [0 for _ in range(19)] for _ in range(19))

def ten(n):
    count2 = 0
    count5 = 0
    while n%2==0:
        count2 += 1
        n //= 2
    while n%5==0:
        count5 += 1
        n //= 5
    count2 = min(count2, 18)
    count5 = min(count5, 18)
    table[count2][count5] += 1
for i in new_a:
    ten(i)

ans = 0
for i in range(19):
    for j in range(19):
        a = table[i][j]
        for k in range(18-i,19):
            for u in range(18-j,19):
                b = table[k][u]
                ans += a*b
                if i==k and j==u:
                  ans -= a
                  
ans //= 2
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [(input()) for _ in range(n)]
new_a = [int(float(i)*(10**9)) for i in a]
table = list( [0 for _ in range(19)] for _ in range(19))

def ten(n):
    count2 = 0
    count5 = 0
    while n%2==0:
        count2 += 1
        n //= 2
    while n%5==0:
        count5 += 1
        n //= 5
    count2 = min(count2, 18)
    count5 = min(count5, 18)
    table[count2][count5] += 1
for i in new_a:
    ten(i)

ans = 0
for i in range(19):
    for j in range(19):
        a = table[i][j]
        for k in range(max(18-i,i),19):
            for u in range(max(18-j,j),19):
                b = table[k][u]
                ans += a*b
    
print(ans)

Submission status: Wrong Answer

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

print(arr)
answer = 0
while len(arr) != 0:
    for i in range(1,len(arr)):
        if round(arr[0] * arr[i], 10) ==  math.floor(arr[0] * arr[i]):
            answer += 1
    arr.pop(0)

print(answer)

Submission status: Wrong Answer

Solution code:
from math import gcd
from collections import Counter

N = int(input())
C = Counter()
for i in range(N):
    x = int(float(input()) * 10 ** 9)
    C[gcd(x, 10**18)] += 1

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

print(int(ans))

Submission status: Wrong Answer

Solution code:
from math import gcd
from collections import Counter

N = int(input())
C = Counter()
for i in range(N):
    x = int(float(input()) * 10 ** 9)
    C[gcd(x, 10**18)] += 1

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

print(ans)

Submission status: Wrong Answer

Solution code:
def solve(a_list):
    cnt = 0
    a_list = [a * 1e9 for a in a_list]
    for a_1 in range(0, len(a_list) - 1):
        for a_2 in range(a_1 + 1, len(a_list)):
            if a_list[a_1] * a_list[a_2] % 1e18 == 0:
                cnt += 1
    print(cnt)


def get_input():
    N = int(input())
    ns = list()
    for i in range(N):
        ns.append(float(input()))
    return ns


solve(a_list=get_input())

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cnt = 0

for i in range(n):
    i1 = i+1
    if i == n-1:
        break
    for j in range(i1, n):
        b = a[i]*a[j]
        if b == int(b):
            cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import bisect
import copy
import heapq
import itertools
import math
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def dev(a):
    d = {}
    for i in (2, 5):
        r = 0
        while a % i == 0:
            r += 1
            a //= i
        d[i] = r
    return d


def main():
    N = int(input())
    A = []
    for _ in range(N):
        a = int(float(input()) * (10 ** 9))
        A.append(dev(a))
    # print(A)
    S = [[0] * 20 for _ in range(20)]
    dp = [[0] * 20 for _ in range(20)]
    for a in A:
        S[min(18, a[2])][min(18, a[5])] += 1

    # print(S)
    for i in range(19):
        for j in range(19):
            dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1] - dp[i][j] + S[i][j]
    
    # print(dp)
    res = 0
    for i, a in enumerate(A):
        s = 18 - min(18, a[2])
        t = 18 - min(18, a[5])
        
        r = N - dp[-1][t] - dp[s][-1] + dp[s][t]
        if a[2] >= 9 and a[5] >= 9:
            r -= 1
        # print(a, r)
        res += r
    print(res // 2)
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
As = [int(float(input())*10**9) for _ in  range(n)]

fives = [0] * n
twos = [0] * n
cnts = [[0] * 20 for i in range(20)]
for i, a in enumerate(As):
    tmp = a
    five = 0
    two = 0
    while tmp % 5 == 0:
        five += 1
        tmp //= 5
    while tmp % 2 == 0:
        two += 1
        tmp //= 2
    cnts[min(two,18)][min(five,18)] += 1
# fiveの和とtwoの和が共に18以上ならOK
# どちらかが18未満ならNG

# 条件を満たすcnts        
ans = 0
for i1 in range(19):
    for j1 in range(19):
        for i2 in range(19):
            for j2 in range(19):
                if i1+i2 >= 18 and j1+j2>=18:
                    ans += cnts[i1][j1]*cnts[i2][j2]
# 自分自身を除外
for i in range(19):
    for j in range(19):
        if i*2 >= 18 and j*2 >= 18:
            ans -= cnts[i][j]

# ダブルカウント
ans //= 2
print(ans)

Submission status: Wrong Answer

Solution code:
N, *A = open(0).read().split()
N = int(N)
A = list(map(float, A))
ans = 0
for i in range(N):
  for j in range(i+1, N):
    f = True
    for k in range(5):
      K = 2 ** k
      x = A[i] * k
      y = A[j] * k
      if abs(x * y - int(x * y)) >= 1e-19:
        f = False
    if f:
      ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
for i in range(N):
    x = float(input())
    A.append(x)
count = 0
for i in range(N):
    for j in range(i+1,N):
        if A[i]*A[j] == int(A[i]*A[j]):
            count +=1
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
numlist = [0] * (N + 1)
log2 = [0] * (N + 1)
log5 = [0] * (N + 1)
acc = [[0 for i in range(19)] for j in range(19)]
Ans = 0

for i in range(1,N+1):
  numlist[i] = float(input()) * 1000000000

  wk = numlist[i]
  for cnt in range(1,19):
    if wk % 2 == 0:
      log2[i] += 1
      wk = wk // 2
    else:
      break
  
  wk = numlist[i]
  for cnt in range(1,19):
    if wk % 5 == 0:
      log5[i] += 1
      wk = wk // 5
    else:
      break

  acc[log2[i]][log5[i]] += 1
    
for i in range(0,19):
  for j in range(0,19): 
    for k in range(i,19):
      for l in range(0,19):
        if (i + k) >=18 and (j + l) >= 18 and (i < k or (i == k and j <= l)):
          if acc[i][j] > 0 and acc[k][l] > 0:
            Ans += acc[i][j] * acc[k][l]
            #print("+:" + str(acc[i][j] * acc[k][l]))
            if i >= 9 and j >= 9 and i == k and j == l and acc[i][j] > 0:
              Ans -= int((acc[i][j] * (acc[i][j] + 1)) / 2)
              #print("-:" + str(acc[i][j]))

print(Ans)
#print(acc)

Submission status: Wrong Answer

Solution code:
N = int(input())
numlist = [0] * (N + 1)
log2 = [0] * (N + 1)
log5 = [0] * (N + 1)
acc = [[0 for i in range(19)] for j in range(19)]
Ans = 0

for i in range(1,N+1):
  numlist[i] = int(float(input()) * 1000000000)


  wk = numlist[i]
  for cnt in range(1,19):
    if wk % 2 == 0:
      log2[i] += 1
      wk = wk // 2
    else:
      break
  
  wk = numlist[i]
  for cnt in range(1,19):
    if wk % 5 == 0:
      log5[i] += 1
      wk = wk // 5
    else:
      break

  acc[log2[i]][log5[i]] += 1
    
for i in range(0,19):
  for j in range(0,19): 
    for k in range(i,19):
      for l in range(0,19):
        if (i + k) >=18 and (j + l) >= 18 and (i < k or (i == k and j <= l)):
          if acc[i][j] > 0 and acc[k][l] > 0:
            Ans += acc[i][j] * acc[k][l]
            #print("+:" + str(acc[i][j] * acc[k][l]))
            if i >= 9 and j >= 9 and i == k and j == l and acc[i][j] > 0:
              Ans -= int((acc[i][j] * (acc[i][j] + 1)) / 2)
              #print("-:" + str(acc[i][j]))

print(Ans)
#print(acc)

Submission status: Wrong Answer

Solution code:
N = int(input())
numlist = [0] * (N + 1)
log2 = [0] * (N + 1)
log5 = [0] * (N + 1)
acc = [[0 for i in range(19)] for j in range(19)]
Ans = 0

for i in range(1,N+1):
  numlist[i] = float(input()) * 1000000000

  wk = numlist[i]
  for cnt in range(1,19):
    if wk % 2 == 0:
      log2[i] += 1
      wk = wk // 2
    else:
      break
  
  wk = numlist[i]
  for cnt in range(1,19):
    if wk % 5 == 0:
      log5[i] += 1
      wk = wk // 5
    else:
      break

  acc[log2[i]][log5[i]] += 1
    
for i in range(0,19):
  for j in range(0,19): 
    for k in range(i,19):
      for l in range(0,19):
        if (i + k) >=18 and (j + l) >= 18 and (i < k or (i == k and j <= l)):
          if acc[i][j] > 0 and acc[k][l] > 0:
            Ans += acc[i][j] * acc[k][l]
#            print("+:" + str(acc[i][j] * acc[k][l]))
            if i >= 9 and j >= 9 and i == k and j == l and acc[i][j] > 0:
              Ans -= int((acc[i][j] * (acc[i][j] + 1)) / 2)
#              print("-:" + str(acc[i][j]))

print(Ans)

Submission status: Wrong Answer

Solution code:
def howmany2_5(x):
    x = x * 10 ** 9
    n2, n5 = 0, 0
    while x % 2 == 0:
        n2 += 1
        x //= 2
    while x % 5 == 0:
        n5 += 1
        x //= 5
    
    if n2 > 18:
        n2 = 18
    if n5 > 18:
        n5 = 18
    
    return (n2, n5)

def lower_bound_0(A, x):
    s, t = -1, len(A)
    while t - s > 1:
        m = (s + t) // 2
        if A[m][0] >= x:
            t = m
        else:
            s = m
    
    return t
    

def upper_bound_0(A, x):
    s, t = -1, len(A)
    while t - s > 1:
        m = (s + t) // 2
        if A[m][0] > x:
            t = m
        else:
            s = m
    
    return t
    
def lower_bound_1(A, x):
    s, t = -1, len(A)
    while t - s > 1:
        m = (s + t) // 2
        if A[m] >= x:
            t = m
        else:
            s = m
            
    return t

def upper_bound_1(A, x):
    s, t = -1, len(A)
    while t - s > 1:
        m = (s + t) // 2
        if A[m] > x:
            t = m
        else:
            s = m
            
    return t


N = int(input())
A = [howmany2_5(float(input())) for _ in range(N)]
A.sort()
B = []
for i in range(19):
    B.append(list(map(lambda x: x[1], A[lower_bound_0(A, i): upper_bound_0(A, i)])))
C = []
for i in range(19):
    C.append([upper_bound_1(B[i], j) - lower_bound_1(B[i], j) for j in range(19)])
    
ans = 0
for i in range(9):
    for j in range(19):
        cnt = C[i][j]
        for k in range(18 - i, 19):
            ans += sum(C[k][18-j:]) * cnt


for i in range(9, 19):
    for j in range(9):
        cnt = C[i][j]
        for k in range(9, 19):
            ans += sum(C[k][18-j:]) * cnt

upper_9_9 = 0
for i in range(9, 19):
    upper_9_9 += sum(C[i][9:])
ans += upper_9_9 * (upper_9_9 - 1) // 2

print(ans)