-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sumto1.py
46 lines (38 loc) · 933 Bytes
/
Sumto1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
def solution(X, Y):
count = 0
A = []
for i in range(len(Y)):
if X[i]<Y[i]:
A.append(X[i]/Y[i])
B = list(set(A))
B = sorted(B)
C = []
for i in B:
C.append(A.count(i))
left = 0
right = len(B)-1
while left<right:
if B[left]+B[right] == 1:
count = count + C[left]*C[right]
left += 1
right -= 1
continue
elif B[left]+B[right]>1:
right -= 1
continue
else :
left += 1
continue
if 0.5 in B:
count = count + sum(C[B.index(0.5)])
return int(count)
pass
def sum(a):
if a>=2:
return a*(a-1)/2
return 0
pass
if __name__ == "__main__":
X = [ int(value) for value in input().split(",") if len(value) > 0 ]
Y = [ int(value) for value in input().split(",") if len(value) > 0 ]
print(solution(X,Y))