結果

問題 No.854 公平なりんご分配
ユーザー qibqib
提出日時 2022-12-29 18:44:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,089 bytes
コンパイル時間 1,699 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 838,816 KB
最終ジャッジ日時 2023-08-16 07:40:09
合計ジャッジ時間 13,049 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
76,964 KB
testcase_01 AC 92 ms
77,040 KB
testcase_02 AC 90 ms
77,168 KB
testcase_03 AC 90 ms
77,196 KB
testcase_04 AC 88 ms
77,196 KB
testcase_05 AC 88 ms
77,000 KB
testcase_06 AC 93 ms
77,252 KB
testcase_07 AC 90 ms
76,976 KB
testcase_08 AC 91 ms
76,968 KB
testcase_09 AC 93 ms
76,984 KB
testcase_10 AC 91 ms
76,716 KB
testcase_11 AC 90 ms
76,992 KB
testcase_12 AC 95 ms
77,012 KB
testcase_13 AC 96 ms
76,916 KB
testcase_14 AC 93 ms
76,928 KB
testcase_15 AC 95 ms
77,012 KB
testcase_16 AC 96 ms
77,004 KB
testcase_17 AC 98 ms
76,928 KB
testcase_18 AC 95 ms
77,004 KB
testcase_19 AC 95 ms
76,968 KB
testcase_20 AC 94 ms
77,056 KB
testcase_21 AC 94 ms
77,108 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 MLE -
testcase_33 MLE -
testcase_34 MLE -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

n = int(input())
a = list(map(int, input().split()))

m = int(math.sqrt(10 ** 9))

dp = [None for _ in range(m + 1)]
s = {}
for x in range(2, m + 1):
  if not dp[x] is None:
    continue
  dp[x] = x
  s[x] = [0 for _ in range(n + 1)]
  for y in range(2 * x, m + 1, x):
    if not dp[y] is None:
      continue
    dp[y] = x

for i in range(n):
  cur = a[i]
  while cur > 1:
    s[dp[cur]][i + 1] += 1
    cur //= dp[cur]

for x in range(2, m + 1):
  if dp[x] == x:
    for i in range(1, n + 1):
      s[x][i] += s[x][i - 1]

q = int(input())
for _ in range(q):
  p, l, r = map(int, input().split())
  l -= 1
  r -= 1
  if p == 1:
    print("Yes")
    continue

  cnt = {}
  cur = p
  for x in range(2, m + 1):
    if cur == 1:
      break
    elif dp[x] != x:
      continue

    if cur % x == 0:
      if x > 2000:
        print("NO")
        continue
      cnt[x] = 0

    while cur % x == 0:
      cnt[x] += 1
      cur //= x

  if cur > 1:
    print("NO")
    continue

  if all(s[x][r + 1] - s[x][l] >= v for x, v in cnt.items()):
    print("Yes")
  else:
    print("NO")
0