結果

問題 No.2758 RDQ
ユーザー 👑 timitimi
提出日時 2024-05-17 21:51:04
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 809 bytes
コンパイル時間 234 ms
コンパイル使用メモリ 82,660 KB
実行使用メモリ 849,264 KB
最終ジャッジ日時 2024-05-17 21:51:12
合計ジャッジ時間 6,480 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
52,456 KB
testcase_01 AC 33 ms
52,852 KB
testcase_02 AC 35 ms
52,932 KB
testcase_03 AC 34 ms
52,880 KB
testcase_04 AC 37 ms
52,868 KB
testcase_05 AC 720 ms
316,808 KB
testcase_06 AC 770 ms
315,992 KB
testcase_07 AC 739 ms
317,680 KB
testcase_08 AC 763 ms
316,580 KB
testcase_09 AC 758 ms
317,528 KB
testcase_10 MLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

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(Q):
  B=list(map(int, input().split()))
  qs.append(B)
  b=B[-1]
  if b not in D:
    D[b]=now
    now+=1

F=[[0]*N for i in range(len(D))]

for i in range(N):
  a=A[i]
  B=make_divisors(a)
  for b in B:
    if b in D:
      F[D[b]][i]+=1

G=[]
for FF in F:
  C=[0]
  for f in FF:
    C.append(C[-1]+f)
  G.append(C)


for l,r,q in qs:
  if q not in D:
    print(0)
  else:
    qq=D[q]
    print(G[qq][r]-G[qq][l-1])
0