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: Time Limit Exceeded

Solution code:
import math
N = int(input())
#N = 1

A = [float(input()) for _ in range(N)]

A = [math.modf(i*10000) for i in A]

counter = 0
for i in range(N-1):
	for j in range(i+1, N):
		num = (A[i][0]*A[j][0] + A[i][0]*A[j][1] + A[i][1]*A[j][0] + A[i][1]*A[j][1])/10000/10000
		#print(num)
		if int(num)==num:
			counter += 1
print(counter)

Submission status: Time Limit Exceeded

Solution code:
from decimal import Decimal
N = int(input())

A = [input() for i in range(N)]
A2 = list(map(Decimal, A))


flg_lst = [0]*N
for i in range(N):
    A_dec = A[i][len(str(int(float(A[i]))))+1:]
    if (len(A_dec) >= 5) and (A_dec[5:]!='0'*len(A_dec[5:])):
        flg_lst[i] = 1
cnt = 0
for i in range(N):
    if flg_lst ==1:
        continue
    for j in range(i+1,N):
        if flg_lst ==1:
            continue
        prod = A2[i]*A2[j]
        if prod == int(prod):
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations

def f(x, y):
    return x*y

N = int(input())
A = [float(input()) for _ in range(N)]

c = list(combinations(A, 2))

cnt = 0
for i in c:
    a0 = str(i[0])[-1]
    a1 = str(i[1])[-1]
    if int(a0)*int(a1) % 10 == 0:
        if f(i[0],i[1]) - int(f(i[0],i[1])) == 0:
            cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())
nums = []
for _ in range(N):
    num = input().split(".")
    if len(num) == 2:
        nums.append([int(num[0]), int(num[1]), len(num[1])])
    else:
        nums.append([int(num[0]),0,0])
ans = 0
for i,j in itertools.combinations(range(N),2):
    l = nums[i][1]*nums[j][1] + nums[i][0]*nums[j][1]*(10**nums[i][2]) + nums[i][1]*nums[j][0]*(10**nums[j][2])
    if l%(10**(nums[i][2]+nums[j][2])) == 0:
        ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from decimal import*
N = int(input())

num_list = []

for _ in range(N):
  num_list.append(float(input()))
  
cnt=0
for i in range(N-1):
  a = str(num_list[i])
  for j in range(i+1,N):
    b = str(num_list[j])
    a = Decimal(a)
    b = Decimal(b)
    c = a*b
    c_int = int(c)
    c_f = c - c_int
    
    if c_f == 0:
      
      cnt+=1
      
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
def main():
    from sys import stdin
    from decimal import Decimal
    readline = stdin.readline
    n = int(readline())
    a = [Decimal(readline()) for i in range(n)]
    count = 0
    for i, an in enumerate(a):
        for j in range(i + 1, len(a)):
            if (an * a[j]) % 1 == 0:
                count = count + 1
    print(count)

main()

Submission status: Time Limit Exceeded

Solution code:
from decimal import Decimal
n = int(input())
a = []
for i in range(n):
    a.append(Decimal(input()))
tmp = 0
ans = 0
for i in range(n):
    for j in range(i + 1, n):
        tmp = a[i] * a[j]
        if tmp % 1 == 0.0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from decimal import *
import math


n = int(input())
ans = 0
vec = [Decimal(input()) for i in range(n)]
vec25 = [[-9, -9] for i in range(n)]  # 整数にするのに余っている2,5の数
for i in range(n):
    a = vec[i] * 1000000000
    while a%2 == 0:
        a //= 2
        vec25[i][0] += 1
    while a%5 == 0:
        a //= 5
        vec25[i][1] += 1
mp = {}
for p in vec25:
    k = p[0] * 10000 + p[1]
    if k in mp:
        mp[k] += 1
    else:
        mp[k] = 1
for k1, v1 in mp.items():
    x5 = k1 % 10000
    while x5 > 100:
        x5 -= 10000
    x2 = (k1 - x5) // 10000
    # print(k1, x2, x5)
    if x5 >= 0 and x2 >= 0:
        ans += v1 * (v1 - 1) // 2
    for k2, v2 in mp.items():
        y5 = k2 % 10000
        while y5 > 100:
            y5 -= 10000
        y2 = (k2 - y5) // 10000
        if x5 + y5 >= 0 and x2 + y2 >= 0 and k1 > k2:
            ans += v1 * v2
print(ans)

Submission status: Time Limit Exceeded

Solution code:


def main():
    from sys import stdin
    from decimal import Decimal
    readline = stdin.readline
    n = int(readline())
    a = [Decimal(readline()) for i in range(n)]
    count = 0
    for i, an in enumerate(a):
        for j in range(i + 1, len(a)):
            v = an * a[j]
            if v % 1 == 0:
                count = count + 1
    print(count)

main()

Submission status: Time Limit Exceeded

Solution code:
#coding:utf-8

N = int(input())

lis = []
ans = 0

for i in range(N):
    k = 0
    A = float(input())

    flag = False
    for a in range(9):
        for b in range(5):
            if(a == 0) and (b == 0):
                continue

            k = (2 ** a) * (5 ** b)

            if k >= 10000:
                continue

            if int(A * k) == A * k:
                flag = True

    if flag:
        lis.append(A)

pon = lis.copy()

for i in lis:
    del pon[0]
    for h in pon:
        if i * h == int(i * h):
            ans += 1

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
from functools import lru_cache


@lru_cache(maxsize=None)
def solve(a, b):
    x = a * b
    return x - int(x) == 0


n = int(input())
arr = [float(input()) for _ in range(n)]
arr = [x for x in arr if x - int(x) >= 0.000005 or x == int(x)]

ans = []
for x, y in combinations(arr, 2):
    ans.append(solve(x, y))

print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
import itertools
from decimal import *

n = int(input())
a = [Decimal(input()) for i in range(n)]

cnt = 0
for i,j in itertools.combinations(list(range(n)), 2):
    if (a[i]*a[j])%Decimal("1") == 0:
        cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import itertools
n=int(input())
l=[]
me=0
for i in range(n):
    x=float(input())
    l.append(x)
y=itertools.combinations(l,2)
for i in y:
    v= i[0]*i[1]
    if int(v)==v and i[0]!=i[1]:
        me+=1
print(me)

Submission status: Time Limit Exceeded

Solution code:
import decimal

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

cnts = [0] * 400

nums = [[0, 0]] * N

for i in range(N):
    A[i] = decimal.Decimal(A[i])
    A[i] *= decimal.Decimal(1000000000)
    A[i] = int(A[i])
    cnt2 = -9
    cnt5 = -9
    while A[i] % 2 == 0:
        cnt2 += 1
        A[i] /= 2
    while A[i] % 5 == 0:
        cnt5 += 1
        A[i] /= 5
    if cnt2 > 9:
        cnt2 = 9
    if cnt5 > 9:
        cnt5 = 9
        
    # print(cnt2, cnt5)
    nums[i] = [cnt2, cnt5]
    cnts[cnt2*20+cnt5+200] += 1

ans = 0
for i in range(N):
    cnt2 = nums[i][0]
    cnt5 = nums[i][1]
    cnts[cnt2*20+cnt5+200] -= 1

    for j in range(-cnt2, 10):
        for k in range(-cnt5, 10):
            # if (cnts[j*20+k+200] > 0):
                # print(i, j, k)
            ans += cnts[j*20+k+200]


print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

A = [int(float(input()) * 10**9) for _ in range(N)]

def func_x(x, n):
    i = 1
    result = 0
    while x % (n**i) == 0:
        result = i
        i += 1
    return result

contain_2 = []
contain_5 = []

for a in A:
    contain_2.append(func_x(a, 2))
    contain_5.append(func_x(a, 5))

ans = 0
for i in range(0, N - 1):
    for j in range(i + 1, N):
        if contain_2[i] + contain_2[j] >= 18:
            if contain_5[i] + contain_5[j] >= 18:
                ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

count = 0
for i in range(N):
    for j in range(i+1, N):
        if Decimal(A[i]) * Decimal(A[j]) % Decimal(1) == 0:
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
"""
AtCoder :: Grand Contest 047 :: Integer Product
https://atcoder.jp/contests/agc047/tasks/agc047_a
"""
import sys


def main():
    """Main program."""
    N = int(sys.stdin.readline())
    nums = []
    for _ in range(N):
        line = sys.stdin.readline().strip()
        tokens = line.split('.')
        if len(tokens) == 1:
            nums.append((int(tokens[0]), 0, float(line)))
        else:
            tokens[1].rstrip('0')
            p = len(tokens[1])
            nums.append((int(tokens[0]+tokens[1]), p, float(line)))
    
    soln = 0
    for i in range(len(nums)):
        for j in range(i+1, len(nums)):
            m = nums[i][0] * nums[j][0]
            if m % pow(10, nums[i][1] + nums[j][1]) == 0:
                soln += 1
    print(soln)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = [0.0] * N
for i in range(N):
    a[i] = float(input())
c = 0
for i in range(N):
  for j in range(i+1,N):
    if (int(a[i]*a[j]) == a[i]*a[j]):
      x = int(a[i]*1000000000)
      y = int(a[j]*1000000000)
      if ((x*y)%1000000000000000000 == 0):
        c = c + 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
n, *a = map(float, open(0).read().split())

m = 1000000000
m2 = m*m
n = int(n)

for i in range(n):
  a[i] = int( a[i] * m )
#  print(a[i])
#
cnt = 0
for i in range(n):
  for j in range(i+1, n):
    if (a[i]*a[j]) % m2 == 0:
      cnt += 1
#
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import sys
import decimal

inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()

A = []
ans = 0

for _ in range(n):
    A.append(decimal.Decimal(input()))

for i in range(n-1):
    for j in range(i+1,n):
        t = A[i]*A[j]
        if t == t//1:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
arr = [float(input()) for _ in range(N)]
count = 0
for i in range(N):
    for j in range(N):
        if arr[i]<arr[j]:
            X = arr[i]*arr[j]
            if X%1 == 0:
                count +=1
print(count)

Submission status: Time Limit Exceeded

Solution code:


def main():
    from sys import stdin
    from decimal import Decimal
    readline = stdin.readline
    n = int(readline())
    a = [Decimal(readline()) for i in range(n)]
    count = 0
    for i, an in enumerate(a):
        for j, am in enumerate(a):
            if i >= j:
                continue
            v = an * am
            if v % 1 == 0:
                count = count + 1
    print(count)


main()

Submission status: Time Limit Exceeded

Solution code:
import math

N = int(input())

A = []
B = []
C = []
for i in range(N):
    s = input()
    if '.' in s:
        a,b = map(int,s.split('.'))
        if(int(b)==0):
            C.append(a)
        else:
            c = a*pow(10,len(s)-s.find('.')-1)+b
            d = pow(10,len(s)-s.find('.')-1)
            g = math.gcd(c,d)
            if(d//g <= 200000):
                A.append(c//g)
                B.append(d//g)
    else:
        C.append(int(s))

ans = len(C) * (len(C)-1) // 2
for i in range(len(A)):
    for j in range(len(C)):
        if A[i]*C[j]%B[i]==0:
            ans += 1
for i in range(len(A)-1):
    for j in range(i+1,len(A)):
        if (A[i]%B[j]==0) and (A[j]%B[i]==0):
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from fractions import Fraction

n=int(input())

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

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

    if a.denominator==1:
        num.append(a)
    elif a.denominator%2==0 and a.denominator%5==0:
        e.append(a)
    elif a.denominator%5==0:
        fiveP.append(a)
    else:
        twoP.append(a)

ans= len(num)*(len(num)-1)//2

for a in twoP:
    for nu in num:
        if nu.numerator%a.denominator==0:
            ans+=1

for a in fiveP:
    for nu in num:
        if nu.numerator%a.denominator==0:
            ans+=1

for a in e:
    for nu in num:
        if nu.numerator%a.denominator==0:
            ans+=1


for a1 in twoP:
    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: Time Limit Exceeded

Solution code:
from decimal import Decimal
n = int(input())
a = []
for i in range(n):
    a.append(float(input()))
count = 0
for i in range(n*n):
    if i%n == i//n:
        pass
    elif (i%n < i//n) and ((Decimal(str(a[i%n])) * Decimal(str(a[i//n]))%1) == 0):
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
s = [float(input()) for i in range(n)]
ans = 0
for i in s:
    for p in s:
        a = i*p
        flag = (a).is_integer()

        if  flag and i != p :
            ans += 1

print(int(ans/2))

Submission status: Time Limit Exceeded

Solution code:
import decimal
N = int(input())
A = [0] * N
for n in range(N):
    A[n] = decimal.Decimal(input())  # float(input())

cnt = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        product = A[i] * A[j]
        # print(f"{A[i]} * {A[j]} = {product}, reverse {product/A[j]}")
        # print(f"mod = {product % decimal.Decimal(1.0)}")
        if product % decimal.Decimal(1.0) == 0:
            cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
from decimal import Decimal
n = int(input())
a = [Decimal(input()) for _ in range(n)]

s = 0
for j in range(n):
    for i in range(j):
        if a[i]*a[j]%1==0:
            s += 1

print(s)

Submission status: Time Limit Exceeded

Solution code:
from fractions import Fraction
N = int(input())
A = []
for _ in range(N):
    A.append(Fraction(input()))
ans=0
for i in range(N):
    for j in range(i+1,N):
        if (A[i]*A[j]).denominator==1:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
l=[]
fint=[False]*N
for i in range(N):
    s=input()
    if '.' in s:
        idx = s.index('.')
        ndec=len(s)-1 - idx
        a = int(s[:idx]+s[idx+1:])
        a *= 10**(9-ndec)
    else:
        a = int(s)
        a *= 10**9
        fint[i] = True
    l.append(a)

ans = 0
for i in range(N):
    a_i = l[i]
    fint_i = fint[i]
    for j in range(i+1,N):
        a_j = l[j]
        fint_j = fint[j]
        if fint_i and fint_j:
            ans += 1
            continue
        m = a_i * a_j
        un = m - (m//(10**18))*10**18
        if un == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from decimal import Decimal

n = int(input())
a = [Decimal(input()) for i in range(n)]


def main():
    count = 0
    for i, an in enumerate(a):
        for j, am in enumerate(a):
            if i >= j:
                continue
            v = an * am
            if v % 1 == 0:
                count = count + 1
    print(count)


main()

Submission status: Time Limit Exceeded

Solution code:
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN

def check(a, b):
    tmp = a * b
    return int(tmp)  == tmp

n = int(input())
A = [Decimal(input()) for _ in range(n)]

cnt = 0
for i in range(n):
    for j in range(i+1, n):
        if check(A[i], A[j]):
            cnt += 1
            # print('ok', A[i], A[j])
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import sys
from fractions import Fraction

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def a(s):
	r = Fraction(s)
	return r.numerator, r.denominator



def main():
	n = int(input())
	#b , c = tin()
	al = [a(input()) for _ in range(n)]
	ret = 0
	for i, (vin, vid) in enumerate(al):
		for (vjn, vjd) in al[i+1:]:
			if (vin*vjn) % (vid* vjd)==0:
				ret += 1
	return ret
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = [0]*n
for i in range(n):
  a = input()
  if not '.' in a:
    l[i] = [int(a) , 0]
  else:
    b,c = a.split('.')
    l[i] = [int(b+c) , len(c)]

count = 0

for i in range(n):
  for j in range(i+1,n):
    if l[i][1] == 0 and l[j][1] == 0:
      count += 1
    elif str(l[i][0]*l[j][0])[-l[i][1]-l[j][1]:] == '0'*(l[i][1]+l[j][1]):
      count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
"""
AtCoder :: Grand Contest 047 :: Integer Product
https://atcoder.jp/contests/agc047/tasks/agc047_a
"""
import sys


def main():
    """Main program."""
    N = int(sys.stdin.readline())
    nums = []
    for _ in range(N):
        line = sys.stdin.readline().strip()
        tokens = line.split('.')
        if len(tokens) == 1:
            nums.append((int(tokens[0]), 0, float(line)))
        else:
            p = len(tokens[1])
            nums.append((int(tokens[0]+tokens[1]), p, float(line)))
    
    soln = 0
    for i in range(len(nums)):
        for j in range(i+1, len(nums)):
            m = nums[i][0] * nums[j][0]
            if m % pow(10, nums[i][1] + nums[j][1]) == 0:
                soln += 1
    print(soln)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = [0.0] * N
for i in range(N):
    a[i] = float(input())
c = 0
for i in range(N):
  for j in range(i+1,N):
    x = int(a[i]*1000000000)
    y = int(a[j]*1000000000)
    if ((x*y)%1000000000000000000 == 0):
      c = c + 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
from decimal import Decimal
n = int(input())
a = []
for i in range(n):
    a.append(float(input()))
count = 0
for i in range(n*n):
    if i%n == i//n:
        pass
    elif (i%n < i//n) and ((Decimal(str(a[i%n])) * Decimal(str(a[i//n]))%1) == 0 or (Decimal(str(a[i%n])) * Decimal(str(a[i//n]))%1)%1 == 0.0):
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
t = int(input())
n = []
ans = 0
for _ in range(t):
    n.append(float(input()))
pairs = []
for i in range(len(n)):
    for j in range(i + 1, len(n)):
        x = n[i] * n[j]
        '''if x == int(x) and [n[i], n[j]] not in pairs:
            print(x, n[i], n[j])
            pairs.append([n[i], n[j]])
            ans += 1'''
        if x == int(x) and n[i] != n[j]:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
readline = sys.stdin.readline
from math import floor
from decimal import Decimal

N = int(readline())
A = [Decimal(readline()) for _ in range(N)]


G = 10**10
Aint = [int(a) for a in A if int(a) == a]
Afl = [int(a*G) for a in A if int(a) != a]


H = 200
geta = 100
Grid = [[0]*H for _ in range(H)]


i25 = []
for ai in Aint:
    i2 = 0
    i5 = 0
    while ai%2 == 0:
        ai //= 2
        i2 += 1
    while ai%5 == 0:
        ai //= 5
        i5 += 1
    i25.append((i2, i5)) 

for af in Afl:
    i2 = -10
    i5 = -10
    while af%2 == 0:
        af //= 2
        i2 += 1
    while af%5 == 0:
        af //= 5
        i5 += 1
    i25.append((i2, i5)) 


for i2, i5 in i25:
    Grid[geta+i2][geta+i5] += 1

for i in range(geta+90, geta-90, -1):
    for j in range(geta+90, geta-90, -1):
        Grid[i][j] += Grid[i][j+1]

for j in range(geta+90, geta-90, -1):
    for i in range(geta+90, geta-90, -1):
        Grid[i][j] += Grid[i+1][j]


lai = len(Aint)
ans = 0
for i2, i5 in i25:
    ans += Grid[geta-i2][geta-i5]
    #print(i2, i5, Grid[geta-i2][geta-i5])
print((ans-lai)//2)

Submission status: Time Limit Exceeded

Solution code:
from decimal import Decimal

n = int(input())
a = [Decimal(input()) for i in range(n)]

count = 0
for i, an in enumerate(a):
    for j, am in enumerate(a):
        if i >= j:
            continue
        v = an * am
        if v % 1 == 0:
            count = count + 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
nums = [float(input()) for x in range(n)]
counts = 0
#print(n,nums)

for i in range(0,n-1):
      for j in range(i+1,n):
            #print(nums[i]*nums[j],end=" & ")
            #print(int(nums[i]*nums[j]),end=" : ")
            if nums[i] != nums[j] and nums[i] * nums[j] == int(nums[i] * nums[j]):
                  #print(str(nums[i]) + " * " + str(nums[j]),end="  ")
                  #print(nums[i]*nums[j],end=" : ")
                  #print("TRUE")
                  counts += 1
            #else:
                  #print("FALSE")

print(counts)

Submission status: Time Limit Exceeded

Solution code:
# cook your dish here
from decimal import *
n = int(input())
l = []
for i in range(n):
    l.append(Decimal(input()))
# print(l)
cnt = 0
for i in range(0,n-1):
    for j in range(i+1, n):
        if Decimal(l[i])*Decimal(l[j])==int(Decimal(l[i])*Decimal(l[j])) and i<j:
            # print(i, j, l[i]*l[j])
            cnt+=1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
from decimal import Decimal
n = int(input())
a = []
for i in range(n):
    a.append(Decimal(input()))
r = 0
for i in range(n):
    for j in range(i + 1, n):

        if (a[i] * a[j]) % 1 == 0: r += 1
print(r)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = []
for i in range(n):
  a.append(float(input()))
m = 0
for i in range(n):
  for j in range(i+1,n):
    if ((a[i]*10)*(a[j]*10)/100).is_integer():
      m += 1
print(m)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = [0]*n
for i in range(n):
  a = input()
  if not '.' in a:
    l[i] = [int(a) , 0]
  else:
    b,c = a.split('.')
    l[i] = [int(b+c) , len(c)]

count = 0

for i in range(n):
  for j in range(i+1,n):
    if l[i][1] == 0 and l[j][1] == 0:
      count += 1
    elif l[i][0]*l[j][0] % 10**(l[i][1]+l[j][1]) == 0:
      count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
import decimal

inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()

A = []
ans = 0

for _ in range(n):
    A.append(float(input()))

for i in range(n-1):
    for j in range(i+1,n):
        if (decimal.Decimal(str(A[i]))*decimal.Decimal(str(A[j]))) == (decimal.Decimal(str(A[i]))*decimal.Decimal(str(A[j])))//1:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
from decimal import Decimal
n = int(input())
num_list = []
for i in range(n):
    num_list.append(Decimal(input()))
count = 0
for i in range(n-1):
    for j in range(i+1,n):
        flt = num_list[i]*num_list[j]
        if flt == int(flt):
            count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
import os
import itertools
import numpy as np
from collections import deque
from decimal import Decimal

def main():
    if os.getenv("ENV")=='LOCAL':
        sys.stdin = open(os.path.dirname(__file__)+'/input.txt', 'r')

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

    ans=0
    for i in range(len(A)-1):
        for j in range(i+1, len(A)):
            if (A[i]*A[j])%1==0:
                # print('A[i]=',A[i],' A[j]=',A[j],' A[i]*A[j]=',A[i]* A[j])
                ans+=1

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,*a = [int(i) for i in read().split()]
n = int(readline())
#a = []
C = [0]*n
D = [0]*n

M = 10**9
for i in range(n):
    bi = float(readline())
    ai = int(round(bi*M))
        
    c2=c5=0    
    x = ai
    while x%2==0:
        c2 += 1
        x//=2
    
    x = ai
    while x%5==0:
        c5 += 1
        x//=5
    #print(ai,c2,c5)
    #a.append((c2,c5,v))
    C[i] = c2
    D[i] = c5
    #print(ai)
#print(C)
#print(D)

ans = 0
for i in range(n):
    for j in range(i+1,n):
        if C[i]+C[j] >= 18 and D[i]+D[j] >= 18:
            ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

A = []
B = []
C = []
for i in range(N):
    s = input()
    if '.' in s:
        a,b = map(int,s.split('.'))
        if(int(b)==0):
            C.append(a)
        else:
            A.append(a*pow(10,len(s)-s.find('.')-1)+b)
            B.append(pow(10,len(s)-s.find('.')-1))
    else:
        C.append(int(s))

ans = len(C) * (len(C)-1) // 2
for i in range(len(A)):
    for j in range(len(C)):
        if A[i]*C[j]%B[i]==0:
            ans += 1
for i in range(len(A)-1):
    for j in range(i+1,len(A)):
        if (A[i]*A[j])%(B[i]*B[j])==0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

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

# 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()
    a = []
    ans = 0
    for i in range(0,n):
        a.append(Decimal(input()))

    for i in range(0, n):
        for ii in range(i+1, n):
            wk = a[i] * a[ii]
            wk = wk - wk.quantize(Decimal('0'), rounding=ROUND_HALF_UP)
            if Decimal.is_zero(wk):
                ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = [0]*n
for i in range(n):
  a = input()
  if not '.' in a:
    l[i] = [int(a) , 0]
  else:
    b,c = a.split('.')
    l[i] = [int(b) * 10**len(c) + int(c) , len(c)]

count = 0

for i in range(n):
  for j in range(i+1,n):
    if l[i][0]*l[j][0] % 10**(l[i][1]+l[j][1]) == 0:
      count += 1

print(count)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=[]
me=0
for i in range(n):
    x=float(input())
    l.append(x)
for j in range(n):
    for k in range(j+1,n):
        re=l[j]*l[k]
        if int(re)==re:
            if l[j]!=l[k]:
                me+=1
print(me)

Submission status: Time Limit Exceeded

Solution code:
from decimal import *

n = int(input())
inputs = []
i = 0
while i < n:
    ip = Decimal(input())
    inputs.append(ip)
    i += 1

pairs = 0
for i in range(n):
    j = i + 1
    while j < n:
        prod = inputs[i] * inputs[j]
        if prod == int(prod):
            pairs += 1
        j+=1
print(pairs)

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left
from decimal import Decimal

N, *A = map(Decimal, open(0).read().split())
N = int(N)

A.sort()
result = 0
for i in range(N):
    if A[i] < 1:
        t = bisect_left(A, 1 // A[i])
    else:
        t = i + 1
    for j in range(t, N):
        t = A[i] * A[j]
        if t == int(t):
            result += 1
print(result)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
from decimal import Decimal
import math
from functools import lru_cache


@lru_cache(maxsize=None)
def solve(a, b):
    x = a * b
    return int(x) == math.ceil(x)


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


ans = []
for x, y in combinations(arr, 2):
    ans.append(solve(x, y))

print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
# problem a
# score 300
from collections import defaultdict
N = int(input())
A = []
from decimal import Decimal
for i in range(N):
    x = float(input())
    x = Decimal(x*(10**9))
    A.append(x)
remove = 0
for i in range(N):
    if (A[i]**2) % (10**18) == 0:
        remove += 1
D = defaultdict(int)
data = []
for x in A:
    order2 = 0
    order5 = 0
    K = x
    while K % 2 == 0:
        order2 += 1
        K = K//2
    while K % 5 == 0:
        order5 += 1
        K = K//5
    data.append((order2, order5))
    for i in range(order2+1):
        for j in range(order5+1):
            D[2**i*5**j] += 1
ans = 0
for ord2, ord5 in data:
    new_ord2 = max(0, 18-ord2)
    new_ord5 = max(0, 18-ord5)
    ans += D[(2**new_ord2)*(5**new_ord5)]
ans-=remove
ans = ans//2
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = input()
n = int(n)
a = []
tp = 0
for i in range(n):
  tp = input()
  tp = float(tp)
  a.append(tp)
ans = 0
for num in a:
  for b in a:
    if b != num:
      c = num*b
      if c.is_integer() == True:
        ans += 1
print(int(ans/2))

Submission status: Time Limit Exceeded

Solution code:

N = int(input())
#整数と整数
#有限整数は、「2^t × 5^f」で表せる。
MN = []
for _ in range(N):
    a = input()
    two = 0
    five = 0
    ten = 0
    if "." in a:
        shosuten = a.index(".")
        ten = len(a) - shosuten - 1
        L = list(a)
        a = int("".join([aa for aa in a if aa!="." ]))
        two = ten
        five = ten
    else:
        a = int(a)
        two = 0
        five = 0  
    while a%5 == 0:
        a //= 5
        five -= 1
    while a%2 == 0:
        a//= 2
        two -= 1
    MN.append((two,five))

ans = 0
for x in range(1,N):
    for y in range(x):
        m1,n1 = MN[x]
        m2,n2 = MN[y]
        if m1+m2 <=0 and n1+n2 <= 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from itertools import combinations
from decimal import Decimal
import math


def solve(a, b):
    x = a * b
    return int(x) == math.ceil(x)


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


ans = []
for x, y in combinations(arr, 2):
    ans.append(solve(x, y))

print(sum(ans))

Submission status: Time Limit Exceeded

Solution code:
import itertools

N = int(input())
#print(N)
A = [int(float(input())*(10**9)) for _ in range(N)]
#print(A)

ans = 0
for a, b in itertools.combinations(A,2):
  #print(a,b)
  if not (a*b)%(10**18):
    ans +=1
    
print(ans)