結果

問題 No.2758 RDQ
ユーザー 👑 timitimi
提出日時 2024-05-18 16:08:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 548 ms / 2,000 ms
コード長 685 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 82,332 KB
実行使用メモリ 193,152 KB
最終ジャッジ日時 2024-05-18 16:08:48
合計ジャッジ時間 10,552 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 423 ms
96,640 KB
testcase_01 AC 34 ms
52,352 KB
testcase_02 AC 34 ms
52,736 KB
testcase_03 AC 34 ms
52,864 KB
testcase_04 AC 33 ms
52,608 KB
testcase_05 AC 35 ms
52,352 KB
testcase_06 AC 504 ms
190,784 KB
testcase_07 AC 511 ms
193,152 KB
testcase_08 AC 548 ms
189,568 KB
testcase_09 AC 511 ms
191,160 KB
testcase_10 AC 528 ms
192,512 KB
testcase_11 AC 490 ms
99,328 KB
testcase_12 AC 498 ms
100,180 KB
testcase_13 AC 491 ms
99,304 KB
testcase_14 AC 511 ms
99,452 KB
testcase_15 AC 528 ms
99,456 KB
testcase_16 AC 481 ms
99,400 KB
testcase_17 AC 520 ms
99,328 KB
testcase_18 AC 498 ms
99,464 KB
testcase_19 AC 499 ms
99,720 KB
testcase_20 AC 526 ms
100,136 KB
testcase_21 AC 36 ms
52,480 KB
testcase_22 AC 35 ms
52,608 KB
testcase_23 AC 33 ms
52,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,Q=map(int, input().split())
A=list(map(int, input().split()))

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]
  
D={}
qs=[];now=0
for i in range(N):
  for a in make_divisors(A[i]):
    if a not in D:
      D[a]=[]
    D[a].append(i)

import bisect
for i in range(Q):
  B=list(map(int, input().split()))
  l,r,x=B 
  l-=1;r-=1
  if x not in D:
    print(0)
  else:
    d=bisect.bisect_right(D[x],r)-bisect.bisect_left(D[x],l)
    print(d)
0