結果

問題 No.854 公平なりんご分配
ユーザー qibqib
提出日時 2022-12-29 19:46:48
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,242 bytes
コンパイル時間 583 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 319,312 KB
最終ジャッジ日時 2023-08-16 08:13:45
合計ジャッジ時間 54,408 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
76,768 KB
testcase_01 AC 85 ms
77,092 KB
testcase_02 AC 84 ms
76,864 KB
testcase_03 AC 86 ms
76,620 KB
testcase_04 AC 83 ms
76,904 KB
testcase_05 AC 84 ms
76,928 KB
testcase_06 AC 84 ms
77,048 KB
testcase_07 AC 83 ms
77,044 KB
testcase_08 AC 84 ms
76,936 KB
testcase_09 AC 83 ms
76,896 KB
testcase_10 AC 85 ms
76,912 KB
testcase_11 AC 87 ms
76,820 KB
testcase_12 AC 89 ms
76,900 KB
testcase_13 AC 86 ms
76,708 KB
testcase_14 AC 83 ms
76,968 KB
testcase_15 AC 85 ms
76,816 KB
testcase_16 AC 87 ms
76,712 KB
testcase_17 AC 86 ms
76,976 KB
testcase_18 AC 85 ms
76,708 KB
testcase_19 AC 87 ms
76,988 KB
testcase_20 AC 87 ms
76,872 KB
testcase_21 AC 89 ms
76,816 KB
testcase_22 AC 180 ms
79,944 KB
testcase_23 AC 115 ms
79,444 KB
testcase_24 AC 161 ms
80,724 KB
testcase_25 AC 122 ms
79,940 KB
testcase_26 AC 171 ms
81,652 KB
testcase_27 AC 124 ms
80,112 KB
testcase_28 AC 155 ms
79,480 KB
testcase_29 AC 103 ms
77,416 KB
testcase_30 AC 132 ms
79,344 KB
testcase_31 AC 156 ms
80,516 KB
testcase_32 AC 376 ms
130,772 KB
testcase_33 AC 467 ms
106,952 KB
testcase_34 AC 680 ms
150,364 KB
testcase_35 AC 598 ms
134,844 KB
testcase_36 AC 532 ms
82,924 KB
testcase_37 AC 361 ms
127,392 KB
testcase_38 AC 323 ms
118,412 KB
testcase_39 AC 994 ms
154,828 KB
testcase_40 AC 543 ms
103,164 KB
testcase_41 AC 561 ms
124,224 KB
testcase_42 AC 621 ms
149,244 KB
testcase_43 AC 1,025 ms
126,204 KB
testcase_44 AC 817 ms
143,676 KB
testcase_45 AC 905 ms
92,812 KB
testcase_46 AC 1,051 ms
142,628 KB
testcase_47 AC 555 ms
114,304 KB
testcase_48 AC 545 ms
147,932 KB
testcase_49 AC 508 ms
149,568 KB
testcase_50 AC 337 ms
126,584 KB
testcase_51 AC 1,209 ms
146,096 KB
testcase_52 AC 788 ms
107,916 KB
testcase_53 AC 372 ms
107,456 KB
testcase_54 AC 632 ms
113,220 KB
testcase_55 AC 304 ms
107,756 KB
testcase_56 AC 293 ms
109,996 KB
testcase_57 AC 514 ms
103,908 KB
testcase_58 AC 915 ms
91,460 KB
testcase_59 AC 290 ms
101,084 KB
testcase_60 AC 486 ms
103,124 KB
testcase_61 AC 370 ms
84,840 KB
testcase_62 AC 603 ms
100,800 KB
testcase_63 AC 414 ms
100,520 KB
testcase_64 AC 299 ms
88,384 KB
testcase_65 AC 415 ms
140,040 KB
testcase_66 AC 472 ms
95,008 KB
testcase_67 AC 523 ms
118,012 KB
testcase_68 AC 557 ms
95,416 KB
testcase_69 AC 365 ms
154,788 KB
testcase_70 AC 297 ms
102,300 KB
testcase_71 AC 300 ms
104,892 KB
testcase_72 AC 805 ms
84,436 KB
testcase_73 AC 352 ms
128,152 KB
testcase_74 AC 567 ms
138,624 KB
testcase_75 AC 443 ms
105,688 KB
testcase_76 AC 470 ms
125,572 KB
testcase_77 AC 501 ms
147,192 KB
testcase_78 AC 811 ms
98,372 KB
testcase_79 AC 603 ms
118,804 KB
testcase_80 AC 674 ms
122,408 KB
testcase_81 AC 428 ms
123,636 KB
testcase_82 MLE -
testcase_83 MLE -
testcase_84 MLE -
testcase_85 MLE -
testcase_86 MLE -
testcase_87 MLE -
testcase_88 MLE -
testcase_89 MLE -
testcase_90 MLE -
testcase_91 MLE -
testcase_92 TLE -
testcase_93 MLE -
権限があれば一括ダウンロードができます

ソースコード

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]

s[0] = [0 for _ in range(n + 1)]
for i in range(n):
  if a[i] == 0:
    s[0][i + 1] += 1

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

q = int(input())
for i in range(q):
  p, l, r = map(int, input().split())
  l -= 1
  r -= 1
  if p == 1 or s[0][r + 1] - s[0][l] > 0:
    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