Problem:


Score : 300 points

Problem Statement

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

Constraints

2 \leq N \leq 200\,000

0 < A_i < 10^4

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

Input

Input is given from Standard Input in the following format.

N
A_1
A_2
\vdots
A_N

Output

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

Sample Input 1

5
7.5
2.4
17.000000001
17
16.000000000

Sample Output 1

3

There are 3 pairs with integer product:

7.5 \cdot 2.4 = 18

7.5 \cdot 16 = 120

17 \cdot 16 = 272

Sample Input 2

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

Sample Output 2

8



Sample input:
5
7.5
2.4
17.000000001
17
16.000000000


Sample output:
3

Submission status: Wrong Answer

Solution code:
N=int(input())

log=[[0 for i in range(19)] for j in range(19)]

#0が多い　13/5が普通  27/11が少ない
ans=0
for _ in range(N):
    A=float(input())*10**9
    
    t_count=0
    f_count=0
    temp=A
    while temp%2==0 and t_count<18:
        temp/=2
        t_count+=1
    temp=A
    while temp%5==0 and f_count<18:
        temp/=5
        f_count+=1
    
    for i in range(19):
        for j in range(19):
            if (A*2**i*5**j)%10**18==0:
                ans+=log[i][j]
    
    log[t_count][f_count]+=1
    
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())

log=[[0 for i in range(12)] for j in range(28)]

two=[2**i for i in range(28)][::-1]
five=[5**i for i in range(12)][::-1]

#0が多い　13/5が普通  27/11が少ない
ans=0
for _ in range(N):
    A=float(input())*2**14*5**6
    if A%1!=0:
        continue
    
    for t_i,item in enumerate(two):
        if A%item==0:
            break
    
    for f_i,item in enumerate(five):
        if A%item==0:
            break

    short_two=t_i-13
    short_five=f_i-5
    
    for i in range(14-short_two):
        for j in range(6-short_five):
            ans+=log[i][j]

    log[t_i][f_i]+=1
    
    

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
for i in range(0,n):
  x=eval(input())
  l.append(x)
c=0
for i in range(0,n):
  for j in range(i+1,n):
    x=l[i]*l[j]
    if int(x)==x:
      c=c+1
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
for i in range(0,n):
    x=eval(input())
    l.append(x)
c=0
for i in range(0,n):
    for j in range(i+1,n):
        x=l[i]*l[j]
        if x==int(x):
            c=c+1
print(c)

Submission status: Wrong Answer

Solution code:
n=int(input())
l=[]
for i in range(0,n):
  x=eval(input())
  l.append(x)
c=0
for i in range(0,n):
  for j in range(i+1,n):
    x=l[i]*l[j]
    if isinstance(x,int):
      c=c+1
      print(x)
print(c)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import decimal
n = int(input())
a=[input() for i in range(n)]
biga=[]
for i in range(n):
    num = decimal.Decimal(a[i])
    biga.append(int(num*10**9))

Submission status: Wrong Answer

Solution code:
import decimal
n = int(input())
a=[input() for i in range(n)]
biga=[]
for i in range(n):
    num = decimal.Decimal(a[i])
    biga.append(int(num*10**9))
def fact25(n):
    cnt2=0
    cnt5=0
    while n%2==0:
        n//=2
        cnt2+=1
    while n%5==0:
        n//=5
        cnt5+=1
    return cnt2,cnt5

arr = [[0 for _ in range(20)] for _ in range(20)]
p25 = []
for i in range(n):
    cnt2,cnt5=fact25(biga[i])
    p25.append([cnt2,cnt5])
    cnt2=min(19,cnt2)
    cnt5=min(19,cnt5)
    arr[cnt2][cnt5]+=1

ans=0
for i in range(20): # 2
    for j in range(20): # 5
        if arr[i][j]==0:
            continue
        for k in range(18-i,20): # 2
            for l in range(18-j,20): # 5
                if i+k>=18 and j+l>=18:
                    if i==k and j==l:
                        ans+= (arr[i][j]-1)*arr[k][l]
                    else:
                        ans+= arr[i][j]*arr[k][l]

print(ans//2)

Submission status: Wrong Answer

Solution code:
import decimal
n = int(input())
a=[input() for i in range(n)]
biga=[]
for i in range(n):
    num = decimal.Decimal(a[i])
    biga.append(int(num*10**9))

def fact25(n):
    cnt2=0
    cnt5=0
    while True:
        if n%2==0:
            n//=2
            cnt2+=1
        else:
            break
    while True:
        if n%5==0:
            n//=5
            cnt5+=1
        else:
            break
    return cnt2,cnt5

arr = [[0 for _ in range(50)] for _ in range(50)]
p25 = []
for i in range(n):
    cnt2,cnt5=fact25(biga[i])
    p25.append([cnt2,cnt5])
    arr[cnt2][cnt5]+=1
ans=0
for i in range(n):
    cnt2,cnt5=p25[i]
    n2=18-cnt2
    n5=18-cnt5
    arr[cnt2][cnt5]-=1
    for j in range(50): # 2
        for k in range(50): # 5
            if j>=n2 and k>=n5:
                ans+=arr[j][k]
    arr[cnt2][cnt5]+=1

Submission status: Wrong Answer

Solution code:
import decimal
n = int(input())
a=[input() for i in range(n)]
biga=[]
for i in range(n):
    num = decimal.Decimal(a[i])
    biga.append(int(num*10**9))

def fact25(n):
    cnt2=0
    cnt5=0
    while True:
        if n%2==0:
            n//=2
            cnt2+=1
        else:
            break
    while True:
        if n%5==0:
            n//=5
            cnt5+=1
        else:
            break
    return cnt2,cnt5

arr = [[0 for _ in range(50)] for _ in range(50)]
for i in range(n):
    cnt2,cnt5=fact25(biga[i])
    arr[cnt2][cnt5]+=1

Submission status: Wrong Answer

Solution code:
def prog(x):
    n = len(x)
    y = [int(i * 10**9) for i in x]
    #y

    def count25(n):
        two = five = 0
        while n % 2 == 0:
            two += 1
            n //= 2
        while n % 5 == 0:
            five += 1
            n //= 5
        return two, five

    d = {}
    for a in y:
        t = count25(a)
        d.setdefault(t, 0)
        d[t] += 1
    two_five = list(d.keys())
    count = 0
    for i in range(len(two_five)): # i = 0
        two, five = two_five[i]
        cnt = d[two_five[i]]
        if two >= 9 and five >= 9:
            count += cnt * (cnt -1) // 2
        for j in range(i + 1, len(two_five)):
            two2, five2 = two_five[j]
            if two + two2 >= 18 and five + five2 >= 18:
                count += cnt * d[two_five[j]]
    print(count)

n = int(input())
x = [0] * n
x = [float(input()) for i in range(n)]
prog(x)

Submission status: Wrong Answer

Solution code:
def prog(x):
    n = len(x)
    y = [int(i * 10**9) for i in x]
    #y

    def count25(n):
        two = five = 0
        while n % 2 == 0:
            two += 1
            n //= 2
        while n % 5 == 0:
            five += 1
            n //= 5
        return two, five

    two = [0] * n
    five = [0] * n
    for i in range(n):
        two[i], five[i] = count25(y[i])
    count = 0
    for i in range(n - 1):
        for j in range(i + 1, n):
            #if min(two[i] + two[j], five[i] + five[j]) >= 18:
            if two[i] + two[j] >= 18 and five[i] + five[j] >= 18:
                #print(min(two1,two2) + min(five1, five2), two1, two2, five1, five2)
                #print(y[i] * y[j], (y[i] * y[j]) / 10**18)
                #print(y[i] / 10**9, y[j] / 10**9)
                #print('=================')
                count += 1
    print(count)

n = int(input())
x = [0] * n
x = [float(input()) for i in range(n)]
prog(x)

Submission status: Wrong Answer

Solution code:
n=int(input())
mat=[[0]*30 for _ in range(30)]
ary=[]
op=5
#a=[]
for _ in range(n):
  t=list(input().split('.'))
  if len(t)==1:
    c=int(t[0])*pow(10,9)
  else:
    c=int(t[0])*pow(10,9)
    r=int((t[1]+'0'*10)[:9])
    c+=r
  n2,n5=0,0
  while (c//pow(2,n2))%2==0:
    n2+=1
  while (c//pow(5,n5))%5==0:
    n5+=1
  n2=min(n2,29-op)
  n5=min(n5,29-op)
  mat[n2+op][n5+op]+=1
  #a.append((c,n2,n5))
  ary.append((n2+op,n5+op))
#for x in a:
#  print(x)
summat=[[0]*31 for _ in range(31)]
for i in range(30):
  for j in range(30):
    summat[i+1][j+1]=summat[i+1][j]+mat[i][j]
for i in range(30):
  for j in range(30):
    summat[i+1][j+1]+=summat[i][j+1]

ans=0
for n2,n5 in ary:
  t2,t5=n2,n5
  t2-=9+op
  t2*=-1
  t2+=9+op
  t5-=9+op
  t5*=-1
  t5+=9+op
  ans+=summat[-1][-1]-summat[t2][-1]-summat[-1][t5]+summat[t2][t5]
  if n2>=9+op and n5>=9+op:ans-=1
print(ans//2)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
mat=[[0]*30 for _ in range(30)]
ary=[]
op=0
for _ in range(n):
  t=list(input().split('.'))
  if len(t)==1:
    c=int(t[0])*pow(10,9)
  else:
    c=int(t[0])*pow(10,9)
    r=int((t[1]+'0'*10)[:9])
    c+=r
  n2,n5=0,0
  while (c//pow(2,n2))%2==0:
    n2+=1
  while (c//pow(5,n5))%5==0:
    n5+=1
  n2=min(n2,9+10)
  n5=min(n5,9+10)
  mat[n2+op][n5+op]+=1
  a.append((c,n2,n5))
  ary.append((n2+op,n5+op))
#for x in a:
#  print(x)
summat=[[0]*31 for _ in range(31)]
for i in range(30):
  for j in range(30):
    summat[i+1][j+1]=summat[i+1][j]+mat[i][j]
for i in range(30):
  for j in range(30):
    summat[i+1][j+1]+=summat[i][j+1]

ans=0
for n2,n5 in ary:
  t2,t5=n2,n5
  t2-=9
  t2*=-1
  t2+=9
  t5-=9
  t5*=-1
  t5+=9
  ans+=summat[-1][-1]-summat[t2][-1]-summat[-1][t5]+summat[t2][t5]
  if n2>=9 and n5>=9:ans-=1
print(ans//2)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
mat=[[0]*30 for _ in range(30)]
ary=[]
op=0
for _ in range(n):
  t=list(input().split('.'))
  if len(t)==1:
    c=int(t[0])*pow(10,9)
  else:
    c=int(t[0])*pow(10,9)
    r=int((t[1]+'0'*10)[:9])
    c+=r
  n2,n5=0,0
  while (c//pow(2,n2))%2==0:
    n2+=1
  while (c//pow(5,n5))%5==0:
    n5+=1
  n2=min(n2,9+1)
  n5=min(n5,9+9)
  mat[n2+op][n5+op]+=1
  a.append((c,n2,n5))
  ary.append((n2+op,n5+op))
#for x in a:
#  print(x)
summat=[[0]*31 for _ in range(31)]
for i in range(30):
  for j in range(30):
    summat[i+1][j+1]=summat[i+1][j]+mat[i][j]
for i in range(30):
  for j in range(30):
    summat[i+1][j+1]+=summat[i][j+1]

ans=0
for n2,n5 in ary:
  t2,t5=n2,n5
  t2-=9
  t2*=-1
  t2+=9
  t5-=9
  t5*=-1
  t5+=9
  ans+=summat[-1][-1]-summat[t2][-1]-summat[-1][t5]+summat[t2][t5]
  if n2>=9 and n5>=9:ans-=1
print(ans//2)

Submission status: Wrong Answer

Solution code:
#a module for any prime implication
import random


def pow(x, y, p):
    res = 1  # Initialize result

    # Update x if it is more
    # than or equal to p
    x = x % p

    if (x == 0):
        return 0

    while (y > 0):

        # If y is odd, multiply
        # x with result
        if ((y & 1) == 1):
            res = (res * x) % p

            # y must be even now
        y = y >> 1  # y = y/2
        x = (x * x) % p

    return res



def primesbelow(N):
    # http://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188
    #""" Input N>=6, Returns a list of primes, 2 <= p < N """
    correction = N % 6 > 1
    N = {0:N, 1:N-1, 2:N+4, 3:N+3, 4:N+2, 5:N+1}[N%6]
    sieve = [True] * (N // 3)
    sieve[0] = False
    for i in range(int(N ** .5) // 3 + 1):
        if sieve[i]:
            k = (3 * i + 1) | 1
            sieve[k*k // 3::2*k] = [False] * ((N//6 - (k*k)//6 - 1)//k + 1)
            sieve[(k*k + 4*k - 2*k*(i%2)) // 3::2*k] = [False] * ((N // 6 - (k*k + 4*k - 2*k*(i%2))//6 - 1) // k + 1)
    return [2, 3] + [(3 * i + 1) | 1 for i in range(1, N//3 - correction) if sieve[i]]

smallprimeset = set(primesbelow(100000))
_smallprimeset = 100000
def isprime(n, precision=7):
    # http://en.wikipedia.org/wiki/Miller-Rabin_primality_test#Algorithm_and_running_time
    if n < 1:
        raise ValueError("Out of bounds, first argument must be > 0")
    elif n <= 3:
        return n >= 2
    elif n % 2 == 0:
        return False
    elif n < _smallprimeset:
        return n in smallprimeset


    d = n - 1
    s = 0
    while d % 2 == 0:
        d //= 2
        s += 1

    for repeat in range(precision):
        a = random.randrange(2, n - 2)
        x = pow(a, d, n)

        if x == 1 or x == n - 1: continue

        for r in range(s - 1):
            x = pow(x, 2, n)
            if x == 1: return False
            if x == n - 1: break
        else: return False

    return True

# https://comeoncodeon.wordpress.com/2010/09/18/pollard-rho-brent-integer-factorization/
def pollard_brent(n):
    if n % 2 == 0: return 2
    if n % 3 == 0: return 3

    y, c, m = random.randint(1, n-1), random.randint(1, n-1), random.randint(1, n-1)
    g, r, q = 1, 1, 1
    while g == 1:
        x = y
        for i in range(r):
            y = (pow(y, 2, n) + c) % n

        k = 0
        while k < r and g==1:
            ys = y
            for i in range(min(m, r-k)):
                y = (pow(y, 2, n) + c) % n
                q = q * abs(x-y) % n
            g = gcd(q, n)
            k += m
        r *= 2
    if g == n:
        while True:
            ys = (pow(ys, 2, n) + c) % n
            g = gcd(abs(x - ys), n)
            if g > 1:
                break

    return g

smallprimes = primesbelow(1000) # might seem low, but 1000*1000 = 1000000, so this will fully factor every composite < 1000000
def primefactors(n, sort=False):
    factors = []

    for checker in smallprimes:
        while n % checker == 0:
            factors.append(checker)
            n //= checker
        if checker > n: break

    if n < 2: return factors

    while n > 1:
        if isprime(n):
            factors.append(n)
            break
        factor = pollard_brent(n) # trial division did not fully factor, switch to pollard-brent
        factors.extend(primefactors(factor)) # recurse to factor the not necessarily prime factor returned by pollard-brent
        n //= factor

    if sort: factors.sort()

    return factors

def factorization(n):
    factors = defaultdict(int)
    for p1 in primefactors(n):
        try:
            factors[p1] += 1
        except KeyError:
            factors[p1] = 1
    return factors

totients = {}
def totient(n):
    if n == 0: return 1

    try: return totients[n]
    except KeyError: pass

    tot = 1
    for p, exp in factorization(n).items():
        tot *= (p - 1)  *  p ** (exp - 1)

    totients[n] = tot
    return tot

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

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


ten9=10**9
ten18=10**18
n=int(input())
from collections import defaultdict
d=defaultdict(int)
for i in range(n):
    s=int(float(input())*ten9)
    #print(s)
    k=factorization(s)
    a=min(k[2],18)
    b=min(k[5],18)
    d[(a,b)]+=1
ans=0
for i in d.keys():
    for j in d.keys():
        if i==j:
            a1, b1 = i
            a2, b2 = j
            if (a1 + a2 >= 18) and (b1 + b2 >= 18):
                ans += (d[i] * (d[j]-1))
            continue
        a1,b1=i
        a2,b2=j
        if (a1+a2>=18) and (b1+b2>=18):
            ans+=(d[i]*d[j])
#print(d)


print(ans//2)

Submission status: Wrong Answer

Solution code:
#a module for any prime implication
import random


def pow(x, y, p):
    res = 1  # Initialize result

    # Update x if it is more
    # than or equal to p
    x = x % p

    if (x == 0):
        return 0

    while (y > 0):

        # If y is odd, multiply
        # x with result
        if ((y & 1) == 1):
            res = (res * x) % p

            # y must be even now
        y = y >> 1  # y = y/2
        x = (x * x) % p

    return res



def primesbelow(N):
    # http://stackoverflow.com/questions/2068372/fastest-way-to-list-all-primes-below-n-in-python/3035188#3035188
    #""" Input N>=6, Returns a list of primes, 2 <= p < N """
    correction = N % 6 > 1
    N = {0:N, 1:N-1, 2:N+4, 3:N+3, 4:N+2, 5:N+1}[N%6]
    sieve = [True] * (N // 3)
    sieve[0] = False
    for i in range(int(N ** .5) // 3 + 1):
        if sieve[i]:
            k = (3 * i + 1) | 1
            sieve[k*k // 3::2*k] = [False] * ((N//6 - (k*k)//6 - 1)//k + 1)
            sieve[(k*k + 4*k - 2*k*(i%2)) // 3::2*k] = [False] * ((N // 6 - (k*k + 4*k - 2*k*(i%2))//6 - 1) // k + 1)
    return [2, 3] + [(3 * i + 1) | 1 for i in range(1, N//3 - correction) if sieve[i]]

smallprimeset = set(primesbelow(100000))
_smallprimeset = 100000
def isprime(n, precision=7):
    # http://en.wikipedia.org/wiki/Miller-Rabin_primality_test#Algorithm_and_running_time
    if n < 1:
        raise ValueError("Out of bounds, first argument must be > 0")
    elif n <= 3:
        return n >= 2
    elif n % 2 == 0:
        return False
    elif n < _smallprimeset:
        return n in smallprimeset


    d = n - 1
    s = 0
    while d % 2 == 0:
        d //= 2
        s += 1

    for repeat in range(precision):
        a = random.randrange(2, n - 2)
        x = pow(a, d, n)

        if x == 1 or x == n - 1: continue

        for r in range(s - 1):
            x = pow(x, 2, n)
            if x == 1: return False
            if x == n - 1: break
        else: return False

    return True

# https://comeoncodeon.wordpress.com/2010/09/18/pollard-rho-brent-integer-factorization/
def pollard_brent(n):
    if n % 2 == 0: return 2
    if n % 3 == 0: return 3

    y, c, m = random.randint(1, n-1), random.randint(1, n-1), random.randint(1, n-1)
    g, r, q = 1, 1, 1
    while g == 1:
        x = y
        for i in range(r):
            y = (pow(y, 2, n) + c) % n

        k = 0
        while k < r and g==1:
            ys = y
            for i in range(min(m, r-k)):
                y = (pow(y, 2, n) + c) % n
                q = q * abs(x-y) % n
            g = gcd(q, n)
            k += m
        r *= 2
    if g == n:
        while True:
            ys = (pow(ys, 2, n) + c) % n
            g = gcd(abs(x - ys), n)
            if g > 1:
                break

    return g

smallprimes = primesbelow(1000) # might seem low, but 1000*1000 = 1000000, so this will fully factor every composite < 1000000
def primefactors(n, sort=False):
    factors = []

    for checker in smallprimes:
        while n % checker == 0:
            factors.append(checker)
            n //= checker
        if checker > n: break

    if n < 2: return factors

    while n > 1:
        if isprime(n):
            factors.append(n)
            break
        factor = pollard_brent(n) # trial division did not fully factor, switch to pollard-brent
        factors.extend(primefactors(factor)) # recurse to factor the not necessarily prime factor returned by pollard-brent
        n //= factor

    if sort: factors.sort()

    return factors

def factorization(n):
    factors = defaultdict(int)
    for p1 in primefactors(n):
        try:
            factors[p1] += 1
        except KeyError:
            factors[p1] = 1
    return factors

totients = {}
def totient(n):
    if n == 0: return 1

    try: return totients[n]
    except KeyError: pass

    tot = 1
    for p, exp in factorization(n).items():
        tot *= (p - 1)  *  p ** (exp - 1)

    totients[n] = tot
    return tot

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

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


ten9=10**9
ten18=10**18
n=int(input())
from collections import defaultdict
d=defaultdict(int)
for i in range(n):
    s=int(float(input())*ten9)
    k=factorization(s)
    a=k[2]
    b=k[5]
    d[(a,b)]+=1
ans=0
for i in d.keys():
    for j in d.keys():
        if i==j:
            a1, b1 = i
            a2, b2 = j
            if a1 + a2 >= 18 and b1 + b2 >= 18:
                ans += (d[i] * (d[j]-1))
            continue
        a1,b1=i
        a2,b2=j
        if a1+a2>=18 and b1+b2>=18:
            ans+=(d[i]*d[j])


print(ans//2)

Submission status: Wrong Answer

Solution code:
import sys
import math
import copy
import heapq
from fractions import *
from decimal import *
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter

sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10 ** 9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n - k])) % MOD


def fact_and_inv(SIZE):
    inv = [0] * SIZE  # inv[j] = j^{-1} mod MOD
    fac = [0] * SIZE  # fac[j] = j! mod MOD
    finv = [0] * SIZE  # finv[j] = (j!)^{-1} mod MOD
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv


def renritsu(A, Y):
    # example 2x + y = 3, x + 3y = 4
    # A = [[2,1], [1,3]])
    # Y = [[3],[4]] または [3,4]
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    # [1.0, 1.0]
    return X.flatten().tolist()[0]


class TwoDimGrid:
    # 2次元座標 -> 1次元
    def __init__(self, h, w, wall="#"):
        self.h = h
        self.w = w
        self.size = (h + 2) * (w + 2)
        self.wall = wall
        self.get_grid()
        # self.init_cost()

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid

    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        # 壁も含めて0-indexed 元々の座標だけ考えると1-indexed
        return y * (self.w + 2) + x

    def getgrid(self, x, y):
        return self.grid[y][x]

    def get(self, x, y):
        return self.cost[self.pos(x, y)]

    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return

    def show(self):
        for i in range(self.h + 2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i + 1)])

    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return

    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        # for i in range(1, self.h+1):
        #     for j in range(1, self.w+1):
        #         cx, cy = j, i
        #         for dx, dy in move_eight:
        #             nx, ny = dx + cx, dy + cy


def so(n):
    ret = []
    for i in range(2, int(math.sqrt(n) + 2)):
        if n % i == 0:
            ret.append(i)

    if ret == []:
        return [n]
    else:
        return ret


def getnig(n):
    ni, go = 0, 0
    while n % 2 == 0:
        ni += 1
        n //= 2
    while n % 5 == 0:
        go += 1
        n //= 5

    return min(18, ni), min(18, go)


def solve():
    # n = getN()
    # nums = []
    # bunsi = [0 for i in range(100)]
    # sei = 0
    # for i in range(n):
    #     S = getS()
    #     if "." not in S:
    #         sei += 1
    #         for sso in so(int(S)):
    #             bunsi[sso] += 1
    #
    #     else:
    #         nums.append(float(S))
    #
    # print(bunsi)
    # print(nums)
    # # for num in nums:
    # #     for s in so(num):
    # #         bunsi[s] += 1
    # # for
    n = getN()
    nums = []
    nigolis = [[0 for i in range(21)] for j in range(21)]
    for i in range(n):
        num = getS()
        if "." in num:
            sei, syo = num.split(".")
            sei = int(sei) * 10 ** 10
            syo = int(syo) * 10 ** (10 - len(syo))
            # print(num)
            # if num == 0:
            #     nigolis[18][18] += 1
            #     nums.append((18,18))
            #     continue
            num = sei + syo
        else:
            num = int(num) * 10 ** 10
        # print(num)
        ni, go = getnig(num)
        # print(ni, go)
        nigolis[ni][go] += 1
        nums.append((ni, go))
    # print(nums)
    for i in range(20):
        for j in range(20):
            nigolis[i][j + 1] += nigolis[i][j]
    # for nigo in nigolis:
    #     print(nigo)
    ans = 0
    for tn, tg in nums:
        for i in range(20 - tn, 21):
            if tg == 20:
                ans += nigolis[i][-1]
            else:
                ans += nigolis[i][-1] - nigolis[i][20 - tg - 1]

        if tn >= 10 and tg >= 10:
            ans -= 1
        # print(ans)

    print(ans // 2)
    # print(Fraction(Decimal("0.3")).denominator)


def main():
    n = getN()
    for _ in range(n):
        solve()

    return


if __name__ == "__main__":
    # main()
    solve()

Submission status: Wrong Answer

Solution code:
"""
https://atcoder.jp/contests/agc047/tasks/agc047_a
"""

Submission status: Wrong Answer

Solution code:
Alist=[]
N=int(input())
for i in range(N):
  Alist.append(float(input()))
def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False
cnt=0
for i in range(N-1):
  for j in range((i+1),N):
    if is_integer_num(Alist[i]*Alist[j]):
      cnt=cnt+1
print(cnt)

Submission status: Wrong Answer

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect

n=int(input())
d={}
res=[[0,0] for _ in range(n)]
for i in range(n):
    a=float(input())
    b=a*pow(10,9)
    x=0
    y=0
    f=True
    while f:
        f=False
        if b%2==0:
            x+=1
            b=b//2
            f=True
        if b%5==0:
            y+=1
            b=b//5
            f=True
    if x*100+y not in d:
        d[x*100+y]=1
    else:
        d[x*100+y]+=1
    res[i]=[x,y]
ans=0
for i in range(n):
    x,y=res[i]
    for j in d:
        xc=j//100
        yc=j%100
        if xc+x>=18 and yc+y>=18:
            if xc==x and yc==y:
              ans+=d[j]-1
            else:
              ans+=d[j]
print(ans//2)

Submission status: Wrong Answer

Solution code:
N= int(input())
A = []
for _ in range(N):
    a = float(input())
    if int(a*10**4)==a*10**4:
        A.append(a)

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

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
list=[]
count=0
n=int(input())
for i in range(n):
  list.append(float(input()))

for i in range(n-1):
  for t in range(i+1,n):
    if list[i]*list[t]==int(list[i]*list[t]):
      count+=1
print(count)

Submission status: Wrong Answer

Solution code:
N=int(input())

log=[[0 for i in range(12)] for j in range(28)]

two=[2**i for i in range(28)][::-1]
five=[5**i for i in range(12)][::-1]

#0が多い　13/5が普通  27/11が少ない
ans=0
for _ in range(N):
    A=float(input())*2**14*5**6
    if A%1!=0:
        continue
    
    for t_i,item in enumerate(two):
        if A%item==0:
            break
    
    for f_i,item in enumerate(five):
        if A%item==0:
            break

    short_two=t_i-13
    short_five=f_i-5
    
    for i in range(14-short_two):
        for j in range(6-short_five):
            ans+=log[i][j]

    log[t_i][f_i]+=1
    
    

print(ans)

Submission status: Wrong Answer

Solution code:
inputs = int(input())
nums = [float(input()) for _ in range(inputs)]

count = 0
for i, num in enumerate(nums):
  j = i +1
  while j < len(nums):
    tmp = num * nums[j]
    if tmp == int(tmp):
      count += 1
    j += 1
print(count)

Submission status: Wrong Answer

Solution code:
inputs = int(input())
nums = [float(input()) for _ in range(inputs)]

count = 0
for i, num in enumerate(nums):
  j = i +1
  while j < len(nums):
    if (num * nums[j]) == int(num * nums[j]):
      count += 1
    j += 1
print(count)

Submission status: Wrong Answer

Solution code:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = float('inf')
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    N = int(input())
    d = [[0] * 19 for _ in range(19)]
    c = []
    for _ in range(N):
        x = round(float(input()) * 10**9)
        d2 = 0
        d5 = 0
        while x % 2 == 0 and d2 < 18:
            x //= 2
            d2 += 1
        while x % 5 == 0 and d5 < 18:
            x //= 5
            d5 += 1
        d[d2][d5] += 1

    a = [[0] * 19 for _ in range(19)]
    for i in range(18,-1,-1):
        s = 0
        for j in range(18,-1,-1):
            s += d[i][j]
            a[i][j] = s
            if i < 18:
                a[i][j] += a[i+1][j]

    ans = 0
    for i in range(18):
        for j in range(18):
            ans += d[i][j] * a[18-i][18-j]
            if i >= 9 and j >=9:
                ans -= d[i][j]


    print(ans//2)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
arr = []
import itertools
for _ in range(int(input())):
  z = float(input())
  arr.append(z)
count = 0
for k in itertools.combinations(arr, 2):
  if k[0]*k[1] == int(k[0]*k[1]):
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
# cook your dish here
n=int(input())
l1=[]
z=n
while n>0:
	k=float(input())
	l1.append(k)
	n=n-1

m=0
for i in range(z):
	for j in range(i,z):
		if i!=j and i<j:
			l=l1[i]*l1[j]
			if l==int(l):
				m=m+1

print(m)

Submission status: Wrong Answer

Solution code:
# cook your dish here
n=int(input())
l1=[]
z=n
while n>0:
	k=float(input())
	l1.append(k)
	n=n-1

m=0
for i in range(z):
	for j in range(z):
		if i!=j and i<j:
			l=l1[i]*l1[j]
			if l==int(l):
				m=m+1

print(m)

Submission status: Wrong Answer

Solution code:
data = []
k = int(input())
for i in range(k):
    data.append(float(input()))
ans = 0
for i in range(len(data)):

    for j in range(i+1,len(data)):

        x = data[i]*data[j]
        if int(x)==x:
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
dp=[[0]*19 for _ in range(19)]
ans=0
for _ in range(n):
  a=int(float(input())*10**9)
  f,t=0,0
  while a%2==0:
    t+=1
    a//=2
  while a%5==0:
    f+=1
    a//=5
  t,f=min(t,18),min(f,18)
  ans+=dp[18-t][18-f]
  for i in range(t+1):
    for j in range(f+1):
      dp[i][j]+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
dp = [[0]*(19) for _ in range(19)]
ans = 0
for _ in range(N):
    a = float(input())*10**9
    two = 0
    five = 0
    while a%2 == 0:
        a //= 2
        two += 1
    while a%5 == 0:
        a //= 5
        five += 1
    two = min(two,18)
    five = min(five,18)
    ans += dp[18-two][18-five]
    for i in range(two+1):
        for j in range(five+1):
            dp[i][j] += 1
print(ans)