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:
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    while b > 0:
        a, b = b, a % b
    return a

n = int(input())
fractions = []

den_num_pair = dict()

for _ in range(n):
    s = input()
    di = 0
    l = len(s)
    while di < l and s[di] != '.':
        di += 1
    num = s[:di]
    if di + 1 < l:
        num += s[di+1:]
        den = 10 ** (l - di - 1)
    else:
        den = 1
    num = int(num)
    g = gcd(num, den)
    num //= g
    den //= g
    if den > 10000:
        continue
    fractions.append((num, den))
    if not den in den_num_pair:
        den_num_pair[den] = dict()

    i = 1
    while i * i <= num:
        if num % i == 0:
            j = num // i
            if not i in den_num_pair[den]:
                den_num_pair[den][i] = 0
            den_num_pair[den][i] += 1
            if not j in den_num_pair[den]:
                den_num_pair[den][j] = 0
            if i != j:
                den_num_pair[den][j] += 1
        i += 1



count = 0
for num, den in fractions:
    di = 1
    while di * di <= num:
        if num % di == 0:
            dj = num // di
            if di in den_num_pair and den in den_num_pair[di]:
                count += den_num_pair[di][den]
            if di != dj and dj in den_num_pair and den in den_num_pair[dj]:
                count += den_num_pair[dj][den]
        di += 1
    if den == 1:
        count -= 1
print(count // 2)

Submission status: Wrong Answer

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

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

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

for x in l_int:
    if x==1:continue
    if x//8==x/8:ans+=len(l_8)
    if x//5==x/5:ans+=len(l_5)
    if x//4==x/4:ans+=len(l_4)
    if x//2==x/2:ans+=len(l_2)
    if x//1000==x/1000:ans+=len(l_1000)
    if x//100==x/100:ans+=len(l_100)
    if x//10==x/10:ans+=len(l_10)

print(int(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [input() for _ in [0]*N]

for i,a in enumerate(A):
    b = a.split(".")
    if len(b)==1:
        A[i] = int(a)*10**9
        continue
    c = b[1]
    n = len(c)
    c += "0"*(9-n)
    A[i] = int(b[0] + c)
exit()
cnt = [[0]*20 for _ in [0]*20]
B = [(0,0)]*N
for k,a in enumerate(A):
    i = 0
    j = 0
    while a%2==0:
        a//=2
        i+=1
    while a%5==0:
        a//=5
        j+=1
    B[k] = (i,j)
    cnt[i][j] += 1

for i in range(1,20):
    i = 19-i
    for j in range(20):
        j = 19-j
        cnt[i][j] += cnt[i+1][j]

for i in range(20):
    i = 19-i
    for j in range(1,20):
        j = 19-j
        cnt[i][j] += cnt[i][j+1]

ans = 0
for i,j in B:
    me = int(i>=9 and j>=9)
    ans += cnt[18-i][18-j]-me

print(ans//2)

Submission status: Wrong Answer

Solution code:
def fact2(a, b):
    c2 = 0
    c5 = 0
    while a%2 == 0:
        a //= 2
        c2 += 1
    while a%5 == 0:
        a //= 5
        c5 += 1
    return min(c2-b, 9), min(c5-b,9)

def main():
    N = int( input())
    A2 = [0]*N
    A5 = [0]*N
    AS = [0]*N
    for i in range(N):
        a = input()
        if '.' in a:
            b, c = a.split('.')
            if int(c) == 0:
                pass
            else:
                AS[i] = len(c)
                b += c
        else:
            b = a
        # A2[i], A5[i] = fact( int(b))
        # print(b)
        A2[i], A5[i] = fact2( int(b), AS[i])

    R = [ [0]*19 for _ in range(19)]
    for i in range(N):
        a, b = A5[i]+9, A2[i]+9
        R[a][b] += 1
    AR = [ [0]*19 for _ in range(19)]
    for i in range(18,-1,-1):
        for j in range(17,-1,-1):
            R[i][j] = R[i][j] + R[i][j+1]
    for j in range(18):
        for i in range(17,-1,-1):
            R[i][j] += R[i+1][j]
    ans = 0
    # print("\n".join( [" ".join( map( str, a)) for a in AR]))
    for k in range(N):
        i, j = A5[k], A2[k]
        if i <= 9 and j <= 9:
            ans += R[-i+9][-j+9]
            # print(-i+9,-j+9)
        if AS[k] == 0:
            ans -= 1
    print(ans//2)

# 2
# 10.73741824 
# 3051.7578125
# 2**30, 2**15

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import decimal

input = sys.stdin.readline
D = decimal.Decimal


def power_2_5(arg):
    n, d = D(arg).as_integer_ratio()

    p2 = 0
    p5 = 0
    for i in range(9):
        if n % 2 == 0:
            n //= 2
            p2 += 1
        else:
            break
    for i in range(9):
        if n % 5 == 0:
            n //= 5
            p5 += 1
        else:
            break
    for i in range(9):
        if d % 2 == 0:
            d //= 2
            p2 -= 1
        else:
            break
    for i in range(9):
        if d % 5 == 0:
            d //= 5
            p5 -= 1
        else:
            break
    return p2, p5


N = int(input())

P = [power_2_5(input()) for _ in range(N)]

arr = [[0] * 19 for _ in range(19)]

for p2, p5 in P:
    arr[p2 + 9][p5 + 9] += 1

cum_arr = [[0] * 19 for _ in range(19)]
for i in range(19):
    cum_arr[-1][i] = arr[-1][i]
    cum_arr[i][-1] = arr[i][-1]
for i in reversed(range(18)):
    for j in reversed(range(18)):
        cum_arr[i][j] = (
            arr[i][j] + cum_arr[i][j + 1] + cum_arr[i + 1][j] - cum_arr[i + 1][j + 1]
        )

ans = -cum_arr[9][9]
for i in range(19):
    for j in range(19):
        ans += arr[i][j] * cum_arr[18 - i][18 - j]

ans //= 2

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
numlist = [0] * (N + 1)
TF = [0] * (N + 1)
Ans = 0

for i in range(1,N+1):
  numlist[i] = float(input())
#  if numlist[i] == int(numlist[i]):
#    TF[i] = 1
  if (numlist[i] * 10000) % 10 != 0:
    TF[i] = 9
  
  
for i in range(1,N+1):
  if TF[i] == 9:
    continue
    
  for j in range(i+1,N+1):
    if TF[j] == 9:
      continue
    else:
      wk = round(numlist[i],9) * round(numlist[j],9)
      if wk.is_integer():
        Ans += 1
    
print(Ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = []
for _ in range(N):
    a = int(float(input())*10**9)
    if a % 10**5 == 0:
        A.append(a)
ans=0
for i in range(len(A)):
    for j in range(i+1,len(A)):
        if A[i]*A[j] % 10**18 == 0 :
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = [float(input()) for i in range(N)]

counter = Counter()
# d = {}
for i in range(N):
    tmp = round(A[i]*1000000000,5)
    # print(tmp)
    if tmp.is_integer():
        
        tmp = int(tmp)
        cnt2 = 0
        cnt5 = 0
        while tmp%2 == 0:
            tmp //= 2
            cnt2 += 1
        while tmp%5 == 0:
            tmp //= 5
            cnt5 += 1
        # print(cnt2,cnt5)
        counter[(cnt2,cnt5)] += 1
ans = 0
# print(counter)
for i in range(75):
    for j in range(40):
        for a in range(max(0,18-i),75):
            for b in range(max(0,18-j),40):
                if i == a and j == b:
                    ans += counter[(i,j)]*(counter[(i,j)]-1)
                else:
                    ans += counter[(i,j)]*counter[(a,b)]
print(ans//2)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction

n=int(input())

num=[]
twoP=[]
fiveP=[]
e=[]

num_num=[[0 for i in range(50)]for j in range(50)]
two_num=[0 for i in range(60)]
five_num=[0 for i in range(60)]




for i in range(n):
    s=input()
    if "." in s: 
        b=len(s.split(".")[1])
    else:
        b=0
    s=int(s.replace(".",""))
    a=Fraction(s,10**b)

    if a.denominator==1:
        num.append(a)
        c=a.numerator
        two=0
        five=0
        while c%2==0:
            c//=2
            two+=1
        while c%5==0:
            c//=5
            five+=1

        # num_num[two][five]+=1
        two_num[two]+=1
        five_num[five]+=1
    elif a.denominator%2==0 and a.denominator%5==0:
        e.append(a)
    elif a.denominator%5==0:
        fiveP.append(a)
        c=a.numerator
        two=0
        # while c%2==0:
        #     c//=2
        #     two+=1
        # two_num[two]+=1

    else:
        twoP.append(a)
        c=a.numerator
        five=0
        # while c%5==0:
        #     c//=5
        #     five+=1
        # five_num[five]+=1
ans= len(num)*(len(num)-1)//2
# print(ans)
for a in twoP:
    c=a.denominator
    count=0
    while c%2==0:
        count+=1
        c//=2
    # print(count,c)
    if count>=50:
        continue
    for i in range(count,50):
        ans+=two_num[i]
# print(ans)

for a in fiveP:
    c=a.denominator
    count=0
    while c%5==0:
        count+=1
        c//=5
    if count>=49:
        continue
    for i in range(count,50):
        ans +=five_num[i]
# print(ans)
for a in e:
    c=a.denominator
    c2,c5=0,0
    while c%2==0:
        c//=2
        c2+=1
    while c%5==0:
        c//=5
        c5+=1
    if c2>=5 or c5>=5:
        continue
    for i in range(c2,4):
        for j in range(c5,4):
            ans+=num_num[i][j]

two=[[0 for i in range(50)]for j in range(50)]
for a in twoP:
    c=a.denominator
    c2=0
    c5=0
    while c%2==0:
        c//=2
        c2+=1
    c=a.numerator
    while c%5==0:
        c//=5
        c5+=1
    two[c2][c5]+=1

for a in fiveP:
    c=a.denominator
    c2=0
    c5=0
    while c%5==0:
        c//=5
        c5+=1
    c=a.numerator
    while c%2==0:
        c//=2
        c2+=1
    for i in range(0,c2+1):
        for j in range(c5,50):
            ans+=two[i][j]

print(ans)
# print(num)
# print(twoP)
# print(fiveP)
# print(e)

Submission status: Wrong Answer

Solution code:
#import numpy as np
def main():
  n=int(input())
  a=[]
  b=[]
  c=[]
  z=0
  for i in range(n):
    tempa=input().split(".")
    if(len(tempa)==1):
      z=z+1
      tempa=int(tempa[0])
      if (tempa % 2) == 0  or (tempa % 5) == 0:
        a.append(int(tempa))
    else:
      ta=int(tempa[1])
      if ta==0:
        z=z+1
        tempa=int(tempa[0])
        if (tempa % 2) == 0  or (tempa % 5) == 0:
          a.append(int(tempa))
      else:
        b.append(int("".join(tempa)))
        c.append(10**len(tempa[1]))
  nz=n-z
  r=z*(z-1)//2
  #a=np.array(a)
  #b=np.array(b)
  #c=np.array(c)
  fz=0
  z=len(a)
  for j in range(z):
    for k in range(nz):
      tempd=a[j]*b[k]
      if (tempd % c[k]) ==0:
        fz=fz+1
  for j in range(nz-1):
    tempc=c[j]
    tempb=b[j]
    for k in range(j+1,nz):
      tempb=tempb*b[k]
      tempc=tempc*c[k]
      if (tempb % tempc) ==0:
        fz=fz+1
  print(r+fz)
main()

Submission status: Wrong Answer

Solution code:
n = int(input())

int_cnt = 0
int_25 = [[0 for _ in range(10)] for _ in range(10)]
float_25 = [[0 for _ in range(10)] for _ in range(10)]
float_2 = [[0 for _ in range(40)] for _ in range(40)]
float_5 = [[0 for _ in range(40)] for _ in range(40)]

for _ in range(n):
    a = float(input())
    if a % 1 == 0:
        int_cnt += 1
        t = 0
        while a % 2 == 0:
            a //= 2
            t += 1
        t = min(t, 9)
        f = 0
        while a % 5 == 0:
            a //= 5
            f += 1
        f = min(f, 9)
        int_25[t][f] += 1
    else:
        a *= 10 ** 9
        a = int(a)
        cnt = 9
        while a % 10 == 0:
            a //= 10
            cnt -= 1
        t = 0
        while a % 2 == 0:
            a //= 2
            t += 1
        f = 0
        while a % 5 == 0:
            a //= 5
            f += 1
        tt = min(t, 9)
        ff = min(f, 9)
        float_25[max(0, cnt - t)][max(0, cnt - f)] += 1
        float_2[tt][max(0, cnt - f)] += 1
        float_5[max(0, cnt - t)][ff] += 1
ans = int_cnt * (int_cnt - 1) // 2
for i in range(10):
    for j in range(10):
        for k in range(i + 1):
            for l in range(j + 1):
                ans += int_25[i][j] * float_25[k][l]

for i in range(-10, 10):
    for j in range(-10, 10):
        for k in range(-10, 10):
            for l in range(-10, 10):
                if (i - j > 0) and (k - l > 0):
                    if i == j == k == l:
                        continue
                    ans += float_2[i][l] * float_5[j][k]
                    
    
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

int_cnt = 0
int_25 = [[0 for _ in range(10)] for _ in range(10)]
float_25 = [[0 for _ in range(10)] for _ in range(10)]
float_2 = [[0 for _ in range(40)] for _ in range(40)]
float_5 = [[0 for _ in range(40)] for _ in range(40)]

for _ in range(n):
    a = float(input())
    if a % 1 == 0:
        int_cnt += 1
        t = 0
        while a % 2 == 0:
            a //= 2
            t += 1
        t = min(t, 9)
        f = 0
        while a % 5 == 0:
            a //= 5
            f += 1
        f = min(f, 9)
        int_25[t][f] += 1
    else:
        a *= 10 ** 9
        a = int(a)
        cnt = 9
        while a % 10 == 0:
            a //= 10
            cnt -= 1
        t = 0
        while a % 2 == 0:
            a //= 2
            t += 1
        f = 0
        while a % 5 == 0:
            a //= 5
            f += 1
        tt = min(t, 9)
        ff = min(f, 9)
        float_25[max(0, cnt - t)][max(0, cnt - f)] += 1
        float_2[tt][max(0, cnt - f)] += 1
        float_5[max(0, cnt - t)][ff] += 1
ans = int_cnt * (int_cnt - 1) // 2
for i in range(10):
    for j in range(10):
        for k in range(i + 1):
            for l in range(j + 1):
                ans += int_25[i][j] * float_25[k][l]

for i in range(-10, 10):
    for j in range(-10, 10):
        for k in range(-10, 10):
            for l in range(-10, 10):
                if (i - j >= 0) and (k - l >= 0):
                    if i == j == k == l:
                        continue
                    ans += float_2[i][l] * float_5[j][k]
                    
    
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
# print(N)
ary=[]
for i in range(N):
  ary.append(float(stdin.readline().rstrip()))
  # stdin.readline().rstrip().split()
  # print(ary[i])
cnt = 0
for i in range(N):
  for j in range(N-i-1):
    # print(i,j+i+1)
    # print(ary[i],ary[i+j+1],(((ary[i]%1)*(ary[j+i+1])%1)))
    if ((ary[i]%1)*(ary[j+i+1]%1))%1 == 0:
      cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

n = int(input())
a = [float(input()) for _ in range(n)]

b = []
for i in range(n):
    s = str(a[i])
    t = s.split(".")
    #print(t)
    if len(t) == 2:
        if len(t[1]) >= 5:
            pass
        else:
            b.append(a[i])
    else:
        if (t[0] == "1e-01" or t[0] == "1e-02" or t[0] == "1e-03" or t[0] == "1e-04"):
            b.append(a[i])
#print(b)
ans = 0
for i in range(len(b)):
    for j in range(i+1,len(b)):
        temp = int(b[i]*10**4) * int(b[j]*10**4)
        if (temp % 10**8 == 0):
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
def solve():
    from collections import defaultdict
    from fractions import Fraction
    n = int(input())
    d = defaultdict(int)
    ans0 = 0
    for i in range(n):
        x = Fraction(input())
        cnt0, cnt5, cnt2 = 0, 0, 0
        for j in range(5):
            if x % 1 == 0:
                break
            else:
                x *= 10
                cnt0 += 1
        if cnt0 == 5:
            continue
        for j in range(4):
            if x % 5 != 0:
                break
            else:
                x //= 5
                cnt5 += 1
        for j in range(4):
            if x % 2 != 0:
                break
            else:
                x //= 2
                cnt2 += 1
        d[(cnt0, cnt2, cnt5)] += 1
        if cnt0 == 0:
            ans0 += 1
    #print(d)
    lis = list(d)
    lis.sort(reverse=True)
    #print(lis)
    ans_f = 0
    for i, (a, b, c) in enumerate(lis):
        if a == 0:
            continue
        k = d[(a, b, c)]
        l = 0
        for x, y, z in lis[i:]:
            if b + y >= a + x and c + z >= a + x:
                l += d[(x, y, z)]
        ans_f += k * l
    print((ans0 * (ans0 - 1)) // 2 + ans_f)
    return
solve()

Submission status: Wrong Answer

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

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

    idx += 1
'''



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

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

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

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

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

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

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

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

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

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

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

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

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


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

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


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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def prime(n):
    ans=[0,0]
    n*=10**9
    while n>0:
        if n%2==0:
            ans[0]+=1
            n//=2
        elif n%5==0:
            ans[1]+=1
            n//=5
        else:
            break
    ans[0]-=9
    ans[1]-=9
    return ans

n=int(input())
a=[float(input()) for _ in range(n)]
b=[prime(a[i]) for i in range(n)]
ans=0
c=[s for s in b if s[0]>=-13 and s[1]>=-5]

d=[[0 for k in range(-13,14)] for l in range(-5,6)]

for i in range(len(c)):
    for k in range(-13,14):
        for l in range(-5,6):
            if c[i][0]>=k and c[i][1]>=l:
                d[l+5][k+13]+=1

for i in range(len(c)):
    ans+=d[-c[i][1]+5][-c[i][0]+13]
    if c[i][0]>=0 and c[i][1]>=0:
        ans-=1
print(ans//2)

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = [float(input()) for i in range(N)]

counter = Counter()
# d = {}
for i in range(N):
    tmp = round(A[i]*1000000000,5)
    # print(tmp)
    if tmp.is_integer():
        
        tmp = int(tmp)
        cnt2 = 0
        cnt5 = 0
        while tmp%2 == 0:
            tmp //= 2
            cnt2 += 1
        while tmp%5 == 0:
            tmp //= 5
            cnt5 += 1
        # print(cnt2,cnt5)
        counter[(cnt2,cnt5)] += 1
ans = 0
# print(counter)
for i in range(55):
    for j in range(26):
        for a in range(max(0,18-i),55):
            for b in range(max(0,18-j),26):
                if i == a and j == b:
                    ans += counter[(i,j)]*(counter[(i,j)]-1)
                    # if counter[(i,j)]*(counter[(i,j)]-1):
                    #     print(i,j,a,b,counter[(i,j)]*(counter[(i,j)]-1))
                else:
                    ans += counter[(i,j)]*counter[(a,b)]
                    # if counter[(i,j)]*counter[(a,b)]:
                    #     print(i,j,a,b,counter[(i,j)]*counter[(a,b)])
print(ans//2)

Submission status: Wrong Answer

Solution code:
def fact2(a, b):
    c2 = 0
    c5 = 0
    while a%2 == 0:
        a //= 2
        c2 += 1
    while a%5 == 0:
        a //= 5
        c5 += 1
    return min(c2-b, 9), min(c5-b,9)

def main():
    N = int( input())
    A2 = [0]*N
    A5 = [0]*N
    AS = [0]*N
    for i in range(N):
        a = input()
        if '.' in a:
            b, c = a.split('.')
            if int(c) == 0:
                pass
            else:
                AS[i] = len(c)
                b += c
        else:
            b = a
        # A2[i], A5[i] = fact( int(b))
        # print(b)
        A2[i], A5[i] = fact2( int(b), AS[i])

    R = [ [0]*19 for _ in range(19)]
    for i in range(N):
        a, b = A5[i]+9, A2[i]+9
        R[a][b] += 1
    AR = [ [0]*19 for _ in range(19)]
    for i in range(18,-1,-1):
        for j in range(17,-1,-1):
            AR[i][j] = R[i][j] + AR[i][j+1]
    for j in range(18):
        for i in range(17,-1,-1):
            AR[i][j] += AR[i+1][j]
    ans = 0
    # print("\n".join( [" ".join( map( str, a)) for a in AR]))
    for k in range(N):
        i, j = A5[k], A2[k]
        if i <= 9 and j <= 9:
            ans += AR[-i+9][-j+9]
        if AS[k] == 0:
            ans -= 1
    print(ans//2)

# 2
# 10.73741824 
# 3051.7578125
# 2**30, 2**15

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import math
N=int(input())

div_dic=defaultdict(int)
def add_fact(x):
  for i in range(1,int(x**0.5)+1):
    if x%i==0:
      div_dic[i]+=1
      if i!=x//i:
        div_dic[x//i]+=1
  return

alist=[]
int_list=[]
for _ in range(N):
  a=input()
  if "." in a:
    seisu,shosu=a.split(".")
    seisu=int(seisu)
    shosu=int(shosu.ljust(9,'0'))
    
    bunshi=10**9*seisu+shosu
    bumbo=10**9
    gcd_bb=math.gcd(bunshi,bumbo)
    bunshi//=gcd_bb
    bumbo//=gcd_bb
    
    if bumbo==1:
      int_list.append(bunshi)
      add_fact(bunshi)
    elif bumbo>10000:
      continue
    else:
      alist.append((bunshi,bumbo))
  else:
    seisu=int(a)
    int_list.append(seisu)
    add_fact(seisu)
#print(int_list,alist,div_dic)

num_int=len(int_list)
answer=num_int*(num_int-1)//2
for bunshi,bumbo in alist:
  answer+=div_dic[bumbo]

#shosudoshi
def set_fact(x):
  ret=set()
  for i in range(1,int(x**0.5)+1):
    if x%i==0:
      ret.add(i)
      ret.add(x//i)
  return ret

#print(alist)
div_dic2=defaultdict(int)
for bunshi,bumbo in alist:
  div_set=set_fact(bunshi)  
  for d in div_set:    
    answer+=div_dic2[(bumbo,d)]
    
  for d in div_set:    
    div_dic2[(d,bumbo)]+=1
#print(div_dic2)
  
print(answer)

Submission status: Wrong Answer

Solution code:
import math
from collections import defaultdict

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n = int(input())
A = []
d = defaultdict(int)
mod = 10 ** 9
for _ in range(n):
    a = int(round(float(input()) * mod))
    A.append(a)
    div_list = make_divisors(a)
    for div in div_list:
        d[div] += 1
ans = 0
for a in A:
    if a % mod != 0:
        t = (mod // math.gcd(a, mod)) * mod
        ans += d[int(t)]
ans += d[mod] * (d[mod] - 1) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
from decimal import Decimal
n = int(input())
int10_list = [0 for i in range(10)]
int_count = 0
float_list = [0 for i in range(10)]
float_list_5 = []
float_list_2468 = []
int_list_5 = []
int_list_2468 = []
count = 0
for i in range(n):
    num = Decimal(input()).normalize()
    if num == int(num):
        num = int(num)
        num_i = num
        counter10 = 0
        while num_i%10 == 0:
            num_i = num_i/10
            counter10 += 1
        if counter10 > 8:
            int10_list[9] += 1
        else:
            int10_list[counter10] += 1
        last_num = int(str(num)[-1])
        if last_num == 5:
            int_list_5.append(num)
        if last_num in set([2,4,6,8]):
            int_list_2468.append(num)
        int_count += 1
    else:
        last_num = int(str(num)[-1])
        digit = len(f'{num:f}'.split('.')[1])
        float_list[digit] += 1
        if last_num == 5:
            float_list_5.append(num)
        if last_num in set([2,4,6,8]):
            float_list_2468.append(num)
"""
print(int10_list)
print(float_list)
print(int_list_5)
print(int_list_2468)
print(float_list_5)
print(float_list_2468)
"""
if int_count > 1:
    count += int_count*(int_count-1)/2
for idx, float_digit in enumerate(float_list):
    count += float_digit*int10_list[idx*1]
for f in float_list_2468:
    for f5_num in float_list_5:
        if (f*f5_num) == int(f*f5_num):
            count += 1
    for i5_num in int_list_5:
        if (f*i5_num) == int(f*i5_num):
            count += 1
for f in float_list_5:
    for i2468_num in int_list_2468:
        if (f*i2468_num) == int(f*i2468_num):
            count += 1
#print("count1" + str(count))
print(int(count))

Submission status: Wrong Answer

Solution code:
from decimal import Decimal, Context
N=int(input())
A=[]
for a in range(N):
    A.append(input())




def decimal_normalize(f):
    """数値fの小数点以下を正規化し、文字列で返す"""
    def _remove_exponent(d):
        return d.quantize(Decimal(1)) if d == d.to_integral() else d.normalize()
    a = Decimal.normalize(Decimal(str(f)))
    b = _remove_exponent(a)
    return str(b)
B=[]
for a in A:
    B.append(decimal_normalize(a))
C=[]
for b in B:
    if len(b)<8:
        C.append(b)

kot=0
for c in range(len(C)):
    i=0
    for ni in range(len(C)-c-1):
        i+=1

        han=float(C[c])*float(C[c+i])

        if han.is_integer():
            kot+=1
print(kot)

Submission status: Wrong Answer

Solution code:
def prime(n):
    ans=[0,0]
    n*=10**9
    while n>0:
        if n%2==0:
            ans[0]+=1
            n//=2
        elif n%5==0:
            ans[1]+=1
            n//=5
        else:
            break
    ans[0]-=9
    ans[1]-=9
    return ans

n=int(input())
a=[float(input()) for _ in range(n)]
b=[prime(a[i]) for i in range(n)]
ans=0
c=[s for s in b if (2**max([0,-s[0]]))*(5**max([0,-s[1]]))<10**4]

d=[[0 for k in range(-13,14)] for l in range(-5,6)]

for i in range(len(c)):
    for k in range(-13,14):
        for l in range(-5,6):
            if c[i][0]>=k and c[i][1]>=l:
                d[l+5][k+13]+=1

for i in range(len(c)):
    ans+=d[-c[i][1]+5][-c[i][0]+13]
    if c[i][0]>=0 and c[i][1]>=0:
        ans-=1
print(ans//2)

Submission status: Wrong Answer

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

n = int(input())
a = [float(input()) for _ in range(n)]

b = []
for i in range(n):
    s = str(a[i])
    t = s.split(".")
    print(t)
    if len(t) == 2:
        if len(t[1]) >= 5:
            pass
        else:
            b.append(a[i])
    else:
        if (t[0] == "1e-01" or t[0] == "1e-02" or t[0] == "1e-03" or t[0] == "1e-04"):
            b.append(a[i])
#print(b)
ans = 0
for i in range(len(b)):
    for j in range(i+1,len(b)):
        temp = int(b[i]*10**4) * int(b[j]*10**4)
        if (temp % 10**8 == 0):
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
from decimal import Decimal, Context
N=int(input())
A=[]
for a in range(N):
    A.append(input())




def decimal_normalize(f):
    """数値fの小数点以下を正規化し、文字列で返す"""
    def _remove_exponent(d):
        return d.quantize(Decimal(1)) if d == d.to_integral() else d.normalize()
    a = Decimal.normalize(Decimal(str(f)))
    b = _remove_exponent(a)
    return str(b)
B=[]
for a in A:
    B.append(decimal_normalize(a))
C=[]
for b in B:
    if len(b)<70:
        C.append(b)

kot=0
for c in range(len(C)):
    i=0
    for ni in range(len(C)-c-1):
        i+=1

        han=float(C[c])*float(C[c+i])

        if han.is_integer():
            kot+=1
print(kot)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [float(input()) for _ in range(n)]
a.sort()
n = 0
for i, b in enumerate(a):
  for c in a[i+1:]:
    if not b < c:
      continue
    if (b*c).is_integer():
      n += 1
print(n)

Submission status: Wrong Answer

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

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

for x in l_int:
    if x==1:continue
    if x//8==x/8:ans+=len(l_8)
    if x//5==x/5:ans+=len(l_5)
    if x//4==x/4:ans+=len(l_4)
    if x//2==x/2:ans+=len(l_2)
    if x//1000==x/1000:ans+=len(l_1000)
    if x//100==x/100:ans+=len(l_100)
    if x//10==x/10:ans+=len(l_10)

print(int(ans))