結果

問題 No.2758 RDQ
ユーザー 👑 timitimi
提出日時 2024-05-17 21:49:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 830 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 848,948 KB
最終ジャッジ日時 2024-05-17 21:49:30
合計ジャッジ時間 6,153 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,256 KB
testcase_01 AC 35 ms
53,236 KB
testcase_02 AC 34 ms
54,332 KB
testcase_03 AC 34 ms
52,656 KB
testcase_04 AC 32 ms
53,196 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
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<=50000:
    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