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:
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]
from decimal import Decimal
n=int(input())
alist=[0]*200001
blist=[]
clist=[]
num2=0
num=0
for i in range(n):
  a=float(input())
  if a.is_integer():
    num+=1
    for i in make_divisors(int(a)):
      alist[i]+=1
  else:
    b=str(a)
    c=Decimal(b).as_integer_ratio()
    blist.append(c[1])
    clist.append(c)
    num2+=1
ans=0
for i in blist:
  if i<200001:
    ans+=alist[i]
ans+=num*(num-1)//2
for i in range(num2):
  for j in range(i+1,num2):
    if(clist[i][0]*clist[j][0])%(clist[i][1]*clist[j][1])==0:
      ans+=1
print(ans)

Submission status: Time Limit Exceeded

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

def main():
    N = int(input().rstrip())
    ans = 0
    A = []
    for _ in range(N):
        A.append(Decimal(input().rstrip()))

    for i, a in enumerate(A):
        for ii, aa in enumerate(A):
            if i >= ii:
                continue
            p = aa * a
            pp = Decimal(int(p))
            if p == pp:
                ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from decimal import Decimal


def main():

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

    ans = 0
    for i in range(N - 1):
        for j in range(i + 1, N):
            tmp = Decimal(A[i] * A[j])
            if tmp - int(tmp) == 0:
                ans += 1
    
    print(f'{ans}')


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def primes(n):
    a = Counter()
    while n % 2 == 0:
        a[2]+=1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f]+=1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n]+=1
    return a

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(str, input().split())) #1行ベクトル
    A = tuple(input() for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    ans=0
    dp=[[0]*19 for _ in range(19)]
    for a in A:
        ta=0
        base=1
        dot=0
        for i in range(len(a)):
            ai=a[-1-i]
            if ai==".":
                dot=i
            else:
                ta+=base*int(ai)
                base*=10
        
        c=primes(ta)
        n2=min(18,c[2]+(9-dot))
        n5=min(18,c[5]+(9-dot))
        t2=18-n2
        t5=18-n5
        for i in range(t2,19):
            for j in range(t5,19):
                ans+=dp[i][j]
        #printe(n2,n5,ans)
        dp[n2][n5]+=1
    print(ans)




if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python
# coding: utf-8

from collections import Counter

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def calc(b, d25):
    d2, d5 = -d25[0], -d25[1]
    while b%2 == 0:
        d2 += 1
        b //= 2
    while b%5 == 0:
        d5 += 1
        b //= 5
    return (d2, d5)

def main():
    n = ri()
    ndic = Counter()
    ans = 0
    for i in range(n):
        a = input()
        d = a.split(".")
        if len(d) == 1:
            m = 0
        else:
            m = len(d[1])
        d25 = [m, m]
        b = int(a.replace(".", ""))
        c25 = calc(b, d25)
        if c25[0] == -9 and c25[1] == -9:
            continue
        for e in ndic:
            if c25[0] + e[0] >= 0 and c25[1] + e[1] >= 0:
                ans += ndic[e]
        ndic[c25] += 1
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from decimal import *
import itertools
n = int(input())
arr = []
count = 0
for _ in range(n):
    arr.append(Decimal(input()))

for pair in itertools.combinations(arr, r=2):
    if (pair[0]*pair[1]) == int(pair[0]*pair[1]):
        count += 1
print(count)

Submission status: Time Limit Exceeded

Solution code:
import sys
import collections
import bisect
import math


def main():
    n = int(input())
    A = [None] * n
    for i in range(n):
        p = int(float(input()) * 10 ** 10)
        A[i] = p

    cnt = 0
    for x in range(n - 1):
        for y in range(x + 1, n):
            xy = str(A[x] * A[y])[::-1]
            if xy[0:min(20, len(xy))] == "00000000000000000000":
                cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

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):
	if s.count('.')==0:
		return int(s), 0
	else:
		p = s.index('.')
		if p == 1 and s[0]=='0':
			return int(s[2:]), len(s) - 2
		else:
			return int(s[:p]+s[p+1:]), len(s)-p-1


def main():
	n = int(input())
	#b , c = tin()
	al = [a(input()) for _ in range(n)]
	ret = 0
	for i, (vi, ki) in enumerate(al):
		for (vj, kj) in al[i+1:]:
			#pa((vi*vj)/(10**20))
			if (vi*vj) % (10**(ki+kj))==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())
newl = []
for i in range(n):
  a = float(input())
  newl.append(a)
newl.sort()
cou = 0
for i in range(n):
    cur = newl[i]
    for j in newl[i+1:]:
        o = cur * j
        if o.is_integer() == True and cur < j:
            cou += 1

print(cou)

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()

c = {}
intc = 0
ints = []
decs = []
for d in A:
    if d in c:
        c[d] += 1
        if d == int(d):
            intc += 1
    else:
        c[d] = 1
        if d == int(d):
            intc += 1
            ints.append(d)
        else:
            decs.append(d)

result = intc * (intc - 1) // 2
for i in range(len(decs)):
    a = decs[i]
    if a < 1:
        t = bisect_left(decs, 1 / a)
    else:
        t = i + 1
    for j in range(t, len(decs)):
        b = decs[j]
        t = a * b
        if t == int(t):
            #print(a, b)
            result += c[a] * c[b]

    if a < 1:
        t = bisect_left(ints, 1 / a)
    else:
        t = 0
    for j in range(t, len(ints)):
        b = ints[j]
        t = a * b
        if t == int(t):
            #print(a, b)
            result += c[a] * c[b]

print(result)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
l=[0]*N
fint=[False]*N
ans = 0
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)
        fint_i=False
    else:
        a = int(s)
        a *= 10**9
        fint_i=True
    fint[i] = fint_i
    l[i]=a
    for j in range(i):
        a_j = l[j]
        fint_j = fint[j]
        if fint_i and fint_j:
            ans += 1
            continue
        m = a * a_j
        un = m%10**18
        if un == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def prime(n):
    ans=[0,0]
    while int(n)!=n:
        if str(n)[-1]=="5":
            ans[0]-=1
            n*=2
        elif int(str(n)[-1])%2==0:
            ans[1]-=1
            n*=5
        else:
            ans[0]-=1
            ans[1]-=1
            n*=10

    while n>0:
        if n%2==0:
            ans[0]+=1
            n//=2
        elif n%5==0:
            ans[1]+=1
            n//=5
        else:
            break
    return ans

n=int(input())
a=[float(input()) for _ in range(n)]
b=[[0,0] for _ in range(n)]
ans=0
for i in range(n):
    b[i][0]=prime(a[i])[0]
    b[i][1]=prime(a[i])[1]


for i in range(n-1):
    ans+=max([0,len([j for j in range(i+1,n) if b[i][0]+b[j][0]>=0 and b[i][1]+b[j][1]>=0])])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from decimal import *
n=int(input())
a=[]
for i in range(n):
	a.append((input()))
print(len([Decimal(a[i])*Decimal(a[j]) for i in range(len(a)) for j in range(i, len(a)) if i<j and Decimal(a[i])*Decimal(a[j])==int(Decimal(a[i])*Decimal(a[j]))]))

Submission status: Time Limit Exceeded

Solution code:
import itertools
from decimal import *
import sys
input = sys.stdin.readline

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:
def main():
    from sys import stdin
    from decimal import Decimal
    import numpy as np
    # read
    readline = stdin.readline
    n = int(readline())
    a = [Decimal(readline()) for _ in range(n)]
    # numpy
    a = np.array(a)
    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:
N=int(input())
S =[float(input()) for k in range(N)]
a=0
for i in range(N):
  for j in range(N-i-1):
    if (S[i]*10*S[i+j+1]%10==0):
      a=a+1
      
print(a)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=[]
b=[]
c=[]
z=0
for i in range(n):
  tempa=input().split(".")
  if(len(tempa)==1):
    z=z+1
    a.append(int(tempa[0]))
  else:
    ta=int(tempa[1])
    if ta==0:
      z=z+1
      a.append(int(tempa[0]))
    else:
      b.append(int("".join(tempa)))
      c.append(10**len(tempa[1]))
nz=n-z
r=n*(n-1)//2
fz=nz*z
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):
  for k in range(j+1,nz):
    tempb=b[j]*b[k]
    tempc=c[j]*c[k]
    if (tempb % tempc) >0:
      fz=fz+1
print(r-fz)

Submission status: Time Limit Exceeded

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

A = [math.modf(float(input())*10000) for _ in range(N)]


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

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n = int(input())
a=[]
for i in range(n):
  a.append(int(float(input())*1000000000))
r=0
for i in range(0,n-1):
  for j in range(i+1,n):
    if (a[i]*a[j])%1000000000000000000==0:
      r=r+1
print(r)

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):
	if s.count('.')==0:
		return int(s)*(10**10)
	else:
		p = s.index('.')
		if p == 1 and s[0]=='0':
			return int(s[2:]+('0'*(12-len(s))))
		else:
			return int(s[:p]+s[p+1:]+('0'*(11-len(s)+p)))


def main():
	n = int(input())
	#b , c = tin()
	al = [a(input()) for _ in range(n)]
	ret = 0
	for i, vi in enumerate(al):
		for vj in al[i+1:]:
			#pa((vi*vj)/(10**20))
			if (vi*vj) % (10**20)==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:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def primes(n):
    a = Counter()
    while n % 2 == 0:
        a[2]+=1
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a[f]+=1
            n //= f
        else:
            f += 2
    if n != 1:
        a[n]+=1
    return a

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(str, input().split())) #1行ベクトル
    A = tuple(input() for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    ans=0
    dp=[[0]*19 for _ in range(19)]
    for a in A:
        ta=0
        base=1
        dot=0
        for i,ai in enumerate(reversed(a)):
            if ai==".":
                dot=i
            else:
                ta+=base*int(ai)
                base*=10
        ta*=10**(9-dot)
        c=primes(ta)
        n2=min(18,c[2])
        n5=min(18,c[5])
        t2=18-n2
        t5=18-n5
        for i in range(t2,19):
            for j in range(t5,19):
                ans+=dp[i][j]
        #printe(n2,n5,ans)
        dp[n2][n5]+=1
    print(ans)




if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

d = []

for k in range(N):
    A = float(input())
    d.append(A)

#print(d)

count = 0
for i in d:
    for j in d:
        if i < j:
            kake = i * j
            if kake.is_integer()== True:
                count += 1
                
print(count)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
li = []
for _ in range(n):
    li.append(float(input()))
cout = 0
for i in li:
    for j in li:
        if i!=j:
            if float(i*j) == float(int(i*j)):
                cout+=1
print(int(cout/2))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
lst = []
new_lst = []
c = 0
for x in range(0, N):
    ele = float(input())
    lst.append(ele)
for i in lst:
    for j in lst:
        if i < j:
            a = i * j
            new_lst.append(a)
for b in new_lst:
    if b.is_integer():
        c += 1
    else:
        c += 0
print(c)

Submission status: Time Limit Exceeded

Solution code:
from math import pow


def _get(x_str):
  if '.' not in x_str:
    return int(x_str), 0
  else:
    num_float = len(x_str.split('.')[1])
    x_int = int(float(x_str.replace('.', '')))
    # print('shit: ', x_int, x_str, float(x_str), num_float, 2.3 * 100000.0)
    return x_int, num_float


def _good(a_str, b_str):
  a_int, a_num_float = _get(a_str)
  b_int, b_num_float = _get(b_str)

  prod_str = str(int(a_int * b_int))

  num_trail_zero = 0
  l = len(prod_str)
  for i in range(l):
    if prod_str[l - i - 1] != '0':
      break
    num_trail_zero += 1

  # print(a_int * b_int, num_trail_zero, a_int, a_num_float, b_int, b_num_float)
  if num_trail_zero >= a_num_float + b_num_float:
    return True
  else:
    return False


def A(n, a):
  ans = 0
  for i in range(n):
    for j in range(i + 1, n):
      if _good(a[i], a[j]):
        ans += 1
  return ans


def main():
  a = []
  n = int(input())
  for i in range(n):
    a.append(input())
  print(A(n, a))


if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
from decimal import Decimal

N = int(input())
A = []

for idx in range (N):
    A.append(Decimal(input()))

result = 0

for idx in range(0,N):
    for idx2 in range(idx+1,N):
        if A[idx] * A[idx2] % 1 == 0:
            result += 1

print(int(result))

Submission status: Time Limit Exceeded

Solution code:
from decimal import*

N = int(input())

num_list = []

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
S =[float(input()) for k in range(N)]
a=0
for i in range(N):
  for j in range(N-i-1):
    if ((S[i]*10)*(S[i+j+1]*10)%1==0):
      if(S[i]*S[i+j+1]%1==0):
        a=a+1
      
print(a)

Submission status: Time Limit Exceeded

Solution code:
import sys
import collections
import bisect
import math


def main():
    n = int(input())
    A = [None] * n
    for i in range(n):
        p = int(float(input()) * 10 ** 10)
        A[i] = p

    cnt = 0
    for x in range(n - 1):
        for y in range(x + 1, n):
            xy = str(A[x] * A[y])[::-1]
            if len(xy) >= 20:
                if xy[0:20] == "00000000000000000000":
                    cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

A = [math.modf(float(input())*10000) for _ in range(N)]


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])
		#print(num)
		if num%100000000==0:
			counter += 1
print(counter)

Submission status: Time Limit Exceeded

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

def main():
    N = int(input().rstrip())
    ans = 0
    A = []
    for _ in range(N):
        ai = Decimal(input().rstrip())
        for a in A:
            p = ai * a
            pp = Decimal(int(p))
            if p == pp:
                ans += 1
        A.append(ai)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
from decimal import *
def intProduct(arr, n):
    count = 0
    a = arr[0]
    b = arr[1] 
  
    for i in range(0, n):  
        for j in range(i + 1, n): 
            if (arr[i] * arr[j])== int(arr[i] * arr[j]): 
                count += 1
    print(count)

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

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

intProduct(arr, n)

Submission status: Time Limit Exceeded

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


@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 min(x - int(x), math.ceil(x) - 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:
from decimal import *


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:
N=int(input())
S =[float(input()) for k in range(N)]
a=0
b=0
for i in range(N):
  for j in range(N-i-1):
    b=b+1
    if ((S[i]*10)*(S[i+j+1]*10)%1==0):
      if(S[i]*S[i+j+1]%1==0):
        a=a+1
      else:
        continue
    else:
      continue
      
print(a)

Submission status: Time Limit Exceeded

Solution code:
# coding = utf-8

import decimal

N = int(input())
lis = []
for _ in range(N):
    lis.append(decimal.Decimal(input()))
    
ans = 0;
for i in range(N):
    for j in range(i+1, N):
        tmp = lis[i] * lis[j]
        if tmp == tmp.to_integral():
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
from decimal import Decimal

N = int(input())
A = []

for idx in range (N):
    A.append(Decimal(input()))

result = 0

for idx in range(0,N):
    for idx2 in range(idx,N):
        if idx == idx2:
            continue
        aaa = A[idx] * A[idx2]
        if aaa % 1 == 0:
            result += 1

print(int(result))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())

Afact = [[0 for _ in range(19)] for _ in range(19)]

ans = 0

for _ in range(N):
    afloat = float(input())
    aint = int(afloat * (10 ** 9) + 0.9)

    fact_count_two = 0
    while aint & 1 == 0:
        fact_count_two += 1
        aint >>= 1
    fact_count_five = 0
    while aint % 5 == 0:
        fact_count_five += 1
        aint //= 5

    ans += Afact[max(0, 18 - fact_count_two)][max(0, 18 - fact_count_five)]
    for i in range(min(fact_count_two + 1, 19)):
        for j in range(min(fact_count_five + 1, 19)):
            Afact[i][j] += 1

print(ans)

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 not a[i]*a[j]%1: s += 1

print(s)

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
        un = m%10**18
        if un == 0:
            ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
def main():
    from itertools import combinations
    N = int(input())
    As = [0.0]*N
    for i in range(N):
        As[i] = float(input())
    count = 0
    for i in range(N):
        for j in range(i+1, N):
            if As[i]*As[j] - int(As[i]*As[j]) == 0.0:
                if str(int(As[i]*10**9)*int(As[j]*10**9))[-18] == '0':
                    count+=1




    return count

if __name__ == '__main__':
    print(main())

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 isinstance(A[i], int) and isinstance(A[j], int):
            count += 1
            continue
        if Decimal(A[i]) * Decimal(A[j]) % Decimal(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 _ 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 bisect import bisect_left
from decimal import Decimal

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

ints = [d for d in A if int(d) == d]
decs = [d for d in A if int(d) != d]

result = len(ints) * (len(ints) - 1) // 2
for i in range(len(decs)):
    a = decs[i]
    if a < 1:
        t = bisect_left(decs, 1 // a)
    else:
        t = i + 1
    for j in range(t, len(decs)):
        t = a * decs[j]
        if t == int(t):
            #print(a, decs[j])
            result += 1

    if a < 1:
        t = bisect_left(ints, 1 // a)
    else:
        t = 0
    for j in range(t, len(ints)):
        t = a * ints[j]
        if t == int(t):
            #print(a, ints[j])
            result += 1

print(result)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = []
for i in range(N):
    a.append(float(input()))
c = 0
b = []
for i in range(N):
    b.append(a[i]* 10000)
for i in range(N-1):
    for j in range(i+1, N):
        if float.is_integer((b[i] * b[j]) / 100000000):
            c += 1
print(c)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys
from decimal import Decimal


def std_in():
    return sys.stdin.readline().strip()


def main():
    n = int(std_in())
    a = [Decimal("0.0")] * n
    for i in range(n):
        a[i] = Decimal(std_in())
    counter = 0
    for i in range(n-1):
        for j in range(i+1, n):
            p = a[i] * a[j]
            if (p - Decimal(str(int(p)))) == Decimal("0"):
                counter += 1
    print(counter)


if __name__ == "__main__":
    main()

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: 
        b=len(s.split(".")[1])
    else:
        b=0
    s=int(s.replace(".",""))
    a=Fraction(s,10**b)

    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)