結果

問題 No.854 公平なりんご分配
ユーザー qibqib
提出日時 2022-12-29 18:14:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,052 bytes
コンパイル時間 1,469 ms
コンパイル使用メモリ 86,356 KB
実行使用メモリ 321,276 KB
最終ジャッジ日時 2023-08-16 07:23:48
合計ジャッジ時間 27,893 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 RE -
testcase_58 RE -
testcase_59 RE -
testcase_60 RE -
testcase_61 RE -
testcase_62 RE -
testcase_63 RE -
testcase_64 RE -
testcase_65 RE -
testcase_66 RE -
testcase_67 RE -
testcase_68 RE -
testcase_69 RE -
testcase_70 RE -
testcase_71 RE -
testcase_72 RE -
testcase_73 RE -
testcase_74 RE -
testcase_75 RE -
testcase_76 RE -
testcase_77 RE -
testcase_78 RE -
testcase_79 RE -
testcase_80 RE -
testcase_81 RE -
testcase_82 MLE -
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
  if x <= 2000:
    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, 2001):
  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("Yes1")
    continue

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

    if cur % x == 0:
      cnt[x] = 0

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

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

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