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())
a=[]
for s in range(n):
  b=input()
  a.append(float(b))
#print(a)
p=0
ans=0
for x in a:
  c=a
  del(c[p])
  p+=1
  for y in c:
    if abs(x*y-int(x*y))<0.0000000000001:
      ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
from decimal import *
import sys

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

N = int(input())

A = [Decimal(input()) for i in range(N)]

nanachi = [[0, 0] for i in range(N)]

eprint(A)

def is_integer(n: Decimal):
  return n == n.to_integral_value()

for i, a in enumerate(A):
  t = 0
  while not is_integer(a):
    a *= 10
    t += 1
  nanachi[i][0] = -t
  nanachi[i][1] = -t
  while a % 2 == 0:
    a = a / 2
    nanachi[i][0] += 1
  while a % 5 == 0:
    a = a / 5
    nanachi[i][1] += 1

eprint(nanachi)

tmp = min(map(min, nanachi))

for i in range(N):
  nanachi[i][0] -= tmp
  nanachi[i][1] -= tmp

eprint(nanachi)

aaa = [[0] * 200 for i in range(200)]

for a in nanachi:
  aaa[a[0]][a[1]] += 1

acc = [[0] * 201 for i in range(201)]

for i in reversed(range(0, 200)):
  for k in reversed(range(0, 200)):
    acc[i][k] = acc[i+1][k] + acc[i][k+1] - acc[i+1][k+1] + aaa[i][k]

res = 0

for a in nanachi:
  i = - (a[0] + 2*tmp)
  k = - (a[1] + 2*tmp)
  res += acc[i][k]
  if a[0] >= -tmp and a[1] >= -tmp:
    res -= 1

res = res // 2

print(res)

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) + count2, -len(s_d) + count5])

    #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:
import sys
import numpy as np


input = sys.stdin.readline
n = int(input())
a = np.array(float(input()))
cnt = 0
zero_cnt = 0
for _ in range(n - 1):
    x = float(input())
    if x == 0:
        zero_cnt += 1
    elif (x * 10000) % 1 == 0:
        cnt += np.count_nonzero(a * x % 1 == 0)
        a = np.append(a, x)
print((zero_cnt * (2 * n - zero_cnt + 1)) // 2 + cnt)

Submission status: Wrong Answer

Solution code:
import re
import sys
import numpy as np
import copy
from collections import deque
input = sys.stdin.readline
np.set_printoptions(precision=9)


def print_ans(N, ar):
    """Test Case
    >>> print_ans(5,[7.5,2.4,17.000000001,17,16.000000000])
    3
    >>> print_ans(11,[0.9,1,1,1.25,2.30000,5,70,0.000000001,9999.999999999,0.999999999,1.000000001])
    8
    """
    ar = deque(ar)
    array = deque()
    array.append(np.array(ar, dtype='float64'))
    for i in range(N-1):
        tmp = ar.popleft()
        ar.append(tmp)
        array.append(np.array(ar, dtype='float64'))
    array = np.array(array)
    ans = 0
    for i in range(N-1):
        a1 = array[i, 0] * (10 ** 9)
        a2 = array[i, 1:N-i] * (10 ** 9)
        tmp_list = a1 * a2
        tmp_list = tmp_list / (10 ** 18)
        ans += np.count_nonzero(tmp_list == np.fix(tmp_list))
    print(ans)


if __name__ == '__main__':
    N = int(input().rstrip())
    ar = [float(input().rstrip()) for _ in range(N)]
    print_ans(N, ar)

Submission status: Wrong Answer

Solution code:
from fractions import Fraction
from decimal import Decimal
n = int(input())
int_list = [[] for i in range(10)]
int10_list = [[] for i in range(10)]
int_count = 0
float_list = [[] 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].append(num)
        else:
            int10_list[counter10].append(num)
        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].append(num)
        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 += len(float_digit)*len(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)<7:
        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 resolve():
    from decimal import Decimal
    N = int(input())
    A = [Decimal(input()) for _ in range(N)]
    targets = []
    cnt = 0
    for a in A:
        if a % Decimal("0.00001") > 0:
            continue
        for b in targets:
            if (a * b) % Decimal("1") == 0:
                cnt += 1
        targets.append(a)
    print(cnt)


resolve()

Submission status: Wrong Answer

Solution code:
N = int(input())
import decimal
a = [decimal.Decimal(input()) for i in range(N)]
count = 0


for i in range(N):
    if a[i]<10**8:
        exit(0)
    for j in range(N):
        if a[i]<10**8:
           exit(0)
        kakeru = a[i]*a[j]
        if i < j:
            if kakeru - int(kakeru) == 0:
                count += 1
                print(a[i])
                print(a[j])

print(count)

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 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 e==0.2 or e==0.4 or e==0.6 or e==0.8 :l_even.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))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = list()
for _ in range(n):
    a.append(float(input()))

a_np = np.array(a)

a_np_array = list()
for i in range(n):   
    a_np_array.append(a_np*a[i])
a_np_array = np.array(a_np_array)
a_np_array = np.triu(a_np_array, k=1)

cnt=0
for i in a_np_array:
    for j in i:
        if j != 0 and j.is_integer():
            cnt+=1
print(cnt)

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)<6:
        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 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('.')
            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)]
    # print(A2)
    # print(A5)
    # print(AS)
    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:
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=tf-8
#

"""
"""

from collections import defaultdict
import bisect

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


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

    print(ans)
                






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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
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('.')
            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)]
    # print(A2)
    # print(A5)
    # print(AS)
    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)

Submission status: Wrong Answer

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

"""
"""

from collections import defaultdict
import bisect

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


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

    print(ans)
                






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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

ans = [[0] * N for n in range(N)]
count = 0
for i in range(N):
    for j in range(i+1, N):
        if ans[i][j] == 0:
            ans[i][j] = (A[i] * A[j])
            if ans[i][j] - int(ans[i][j]) == 0:
                count += 1

print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = []
for i in range(n):
    tmp = input()
    if '.' in tmp:
        ftmp = float(tmp)
        itmp = int(tmp.replace('.',''))
        for ii in range(9):
            if round(ftmp*1e9)==itmp:
                a.append(int(itmp))
                break
            itmp*=10
        
    else:
        a.append(int(int(tmp)*1e9))
ans = 0

for i in range(n-1):
    for j in range(i+1, n):
        if (a[i]*a[j])%1e18 == 0 and a[i]*a[j] >= 1e18:
            ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[]
for s in range(n):
  b=input()
  a.append(float(b))
#print(a)
p=0
ans=0
for x in a:
  c=a
  del(c[p])
  p+=1
  for y in c:
    parameter = x*y
    if x*y-int(x*y)<0.0000000000001:
      ans+=1
print(ans)

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]


# for a1 in twoP:
#     if a1.numerator%5!=0:
#         continue
#     for a2 in fiveP:
#         if a1.numerator%a2.denominator==0 and a2.numerator%a1.denominator==0:
#             ans+=1


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

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(10)] for _ in range(10)]
float_5 = [[0 for _ in range(10)] for _ in range(10)]

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 = max(t - cnt + 1, 0)
        ff = max(f - cnt + 1, 0)
        tt = min(tt, 9)
        ff = min(ff, 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):
    for j in range(10):
        for k in range(10):
            for l in range(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 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]


for a1 in twoP:
    if a1.numerator%5!=0:
        continue
    for a2 in fiveP:
        if a1.numerator%a2.denominator==0 and a2.numerator%a1.denominator==0:
            ans+=1


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

Submission status: Wrong Answer

Solution code:
cand = list(set([2**x * 5**y for x in range(18)
                 for y in range(8) if 2**x * 5**y <= 200000]))
cand.sort()


def f(n):
    for i in cand:
        x = n * i
        if x.is_integer():
            return i
    else:
        return None


def div(n, bl=True):
    if n is None:
        return (-1, -1)
    if n == -1:
        return (-1, -1)
    if n == 10**9 + 1:
        return (False, False)
    elif bl and not n.is_integer():
        return (0, 0)
    else:
        n = int(n)
        two = format(n, 'b')[::-1].find('1')
        if two < 0:
            return(-1, -1)
        n = n >> two
        cnt = 0
        while n % 5 == 0:
            n //= 5
            cnt += 1
        return (two, cnt)


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

x = [div(x) for x in arr]
y = [div(x, False) for x in [f(x) for x in arr]]
z = [div(x * 2**y1 * 5**z, False) for x, (y1, z) in zip(arr, y)]


ans = 0
for i in range(len(y)):
    for j in range(i + 1, len(y)):
        (a, b), (c, d) = y[i], y[j]
        if a == -1 or b == -1 or c == -1 or d == -1:
            continue
        elif a == 0 and b == 0 and c == 0 and d == 0:
            ans += 1
        elif a + c <= z[i][0] + z[j][0] and b + d <= z[i][1] + z[j][1]:
            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(6):
            if x % 1 == 0:
                break
            else:
                x *= 10
                cnt0 += 1
        if cnt0 == 6:
            continue
        for j in range(6):
            if x % 5 != 0:
                break
            else:
                x //= 5
                cnt5 += 1
        for j in range(6):
            if x % 2 != 0:
                break
            else:
                x //= 2
                cnt2 += 1
        d[(cnt0, cnt2, cnt5)] += 1
        ans0 += cnt0
    lis = list(d)
    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 a == x and b == y and c == z:
                continue
            if b + y >= a and c + z >= a:
                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 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:
        if x-x//1==0.5:l_2.append(x)
        if x-x//1==0.25:l_4.append(x)
        if x-x//1==0.2:l_5.append(x)
        if x-x//1==0.125:l_8.append(x)
        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*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:
def resolve():
    from decimal import Decimal
    N = int(input())
    A = [Decimal(input()) for _ in range(N)]
    targets = []
    cnt = 0
    for a in A:
        if a % Decimal("0.0001") > 0:
            continue
        for b in targets:
            if (a * b) % Decimal("1") == 0:
                cnt += 1
        targets.append(a)
    print(cnt)


resolve()

Submission status: Wrong Answer

Solution code:
from fractions import Fraction

n=int(input())

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

num_num=[[0 for i in range(6)]for j in range(6)]
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]


for a1 in twoP:
    if a1.numerator%5!=0:
        continue
    for a2 in fiveP:
        if a1.numerator%a2.denominator==0 and a2.numerator%a1.denominator==0:
            ans+=1


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