Algorithm/ct/l2/两数乘积k.py

14 lines
319 B
Python
Raw Permalink Normal View History

2022-10-28 02:37:25 +08:00
from bisect import *
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
pair = [0, 0, 0]
for idx in range(n - 1):
l = bisect_left(a, k / a[idx], idx + 1, n)
r = bisect_right(a, k / a[idx], idx + 1, n)
pair[0] += n - r
pair[1] += r - l
pair[2] += l - idx - 1
print(*pair)