結果
| 問題 |
No.2758 RDQ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-17 21:28:47 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 716 ms / 2,000 ms |
| コード長 | 957 bytes |
| コンパイル時間 | 218 ms |
| コンパイル使用メモリ | 82,376 KB |
| 実行使用メモリ | 206,776 KB |
| 最終ジャッジ日時 | 2024-12-20 15:38:57 |
| 合計ジャッジ時間 | 14,222 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)
#input = sys.stdin.readline
#n = int(input())
#
#alist = []
#s = input()
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]
n,q = map(int,input().split())
#for i in range(n):
# alist.append(list(map(int,input().split())))
alist = list(map(int,input().split()))
c = collections.defaultdict(list)
for i in range(n):
y = make_divisors(alist[i])
for j in y:
c[j].append(i)
for i in range(q):
l,r,k = map(int,input().split())
l -= 1
r -= 1
le = bisect.bisect_left(c[k],l)
ri = bisect.bisect_right(c[k],r)
print(ri-le)