結果

問題 No.854 公平なりんご分配
ユーザー qibqib
提出日時 2022-12-29 19:14:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,116 bytes
コンパイル時間 1,175 ms
コンパイル使用メモリ 87,300 KB
実行使用メモリ 321,060 KB
最終ジャッジ日時 2023-08-16 07:53:21
合計ジャッジ時間 43,195 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
77,040 KB
testcase_01 AC 86 ms
76,984 KB
testcase_02 AC 87 ms
76,880 KB
testcase_03 AC 86 ms
76,852 KB
testcase_04 AC 82 ms
76,752 KB
testcase_05 AC 85 ms
76,788 KB
testcase_06 AC 84 ms
77,040 KB
testcase_07 AC 84 ms
77,088 KB
testcase_08 AC 86 ms
76,932 KB
testcase_09 AC 85 ms
77,052 KB
testcase_10 AC 86 ms
77,080 KB
testcase_11 AC 86 ms
76,912 KB
testcase_12 AC 86 ms
77,080 KB
testcase_13 AC 85 ms
77,068 KB
testcase_14 AC 82 ms
76,676 KB
testcase_15 AC 86 ms
76,940 KB
testcase_16 AC 88 ms
76,840 KB
testcase_17 AC 87 ms
76,716 KB
testcase_18 AC 86 ms
77,080 KB
testcase_19 AC 87 ms
76,872 KB
testcase_20 AC 84 ms
77,060 KB
testcase_21 AC 85 ms
77,108 KB
testcase_22 AC 160 ms
79,764 KB
testcase_23 AC 118 ms
79,396 KB
testcase_24 AC 163 ms
80,724 KB
testcase_25 AC 123 ms
79,932 KB
testcase_26 AC 165 ms
81,112 KB
testcase_27 AC 123 ms
80,284 KB
testcase_28 AC 152 ms
79,300 KB
testcase_29 AC 103 ms
76,976 KB
testcase_30 AC 133 ms
79,544 KB
testcase_31 AC 157 ms
80,576 KB
testcase_32 AC 358 ms
130,188 KB
testcase_33 AC 465 ms
106,832 KB
testcase_34 AC 665 ms
150,052 KB
testcase_35 AC 578 ms
134,920 KB
testcase_36 AC 488 ms
83,368 KB
testcase_37 AC 354 ms
127,008 KB
testcase_38 AC 317 ms
118,336 KB
testcase_39 AC 974 ms
154,492 KB
testcase_40 AC 524 ms
102,244 KB
testcase_41 AC 515 ms
123,332 KB
testcase_42 AC 574 ms
148,760 KB
testcase_43 AC 982 ms
125,556 KB
testcase_44 AC 731 ms
143,168 KB
testcase_45 AC 876 ms
91,948 KB
testcase_46 AC 946 ms
142,396 KB
testcase_47 AC 538 ms
114,140 KB
testcase_48 AC 541 ms
147,812 KB
testcase_49 AC 528 ms
149,364 KB
testcase_50 AC 330 ms
126,500 KB
testcase_51 AC 1,175 ms
145,564 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 WA -
testcase_80 WA -
testcase_81 WA -
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 = 2000
k = int(math.sqrt(10 ** 9))

dp = [None for _ in range(k + 1)]
s = {}
for x in range(2, k + 1):
  if not dp[x] is None:
    continue
  dp[x] = x
  if x <= m:
    s[x] = [0 for _ in range(n + 1)]
  for y in range(2 * x, k + 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
  flg = True
  for x in range(2, k + 1):
    if cur == 1:
      break
    if dp[x] != x or cur % x != 0:
      continue

    if x > m:
      flg = False
      break

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

  if not flg or 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