結果

問題 No.854 公平なりんご分配
ユーザー qibqib
提出日時 2022-12-29 18:31:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,014 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 86,852 KB
実行使用メモリ 317,528 KB
最終ジャッジ日時 2023-08-16 07:34:58
合計ジャッジ時間 47,002 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
75,776 KB
testcase_01 AC 83 ms
75,936 KB
testcase_02 AC 78 ms
75,704 KB
testcase_03 AC 85 ms
76,036 KB
testcase_04 AC 78 ms
75,740 KB
testcase_05 AC 82 ms
76,048 KB
testcase_06 AC 80 ms
75,876 KB
testcase_07 AC 82 ms
75,804 KB
testcase_08 AC 80 ms
76,016 KB
testcase_09 AC 79 ms
75,876 KB
testcase_10 AC 81 ms
76,048 KB
testcase_11 AC 79 ms
76,068 KB
testcase_12 AC 81 ms
76,100 KB
testcase_13 AC 80 ms
76,000 KB
testcase_14 AC 77 ms
76,056 KB
testcase_15 AC 82 ms
75,760 KB
testcase_16 AC 80 ms
75,924 KB
testcase_17 AC 82 ms
76,044 KB
testcase_18 AC 80 ms
75,996 KB
testcase_19 AC 82 ms
76,116 KB
testcase_20 AC 81 ms
76,048 KB
testcase_21 AC 83 ms
75,904 KB
testcase_22 AC 127 ms
78,676 KB
testcase_23 AC 102 ms
76,316 KB
testcase_24 AC 135 ms
79,980 KB
testcase_25 AC 102 ms
76,352 KB
testcase_26 AC 144 ms
79,968 KB
testcase_27 AC 108 ms
76,352 KB
testcase_28 AC 127 ms
78,868 KB
testcase_29 AC 94 ms
76,316 KB
testcase_30 AC 102 ms
76,384 KB
testcase_31 AC 140 ms
79,696 KB
testcase_32 AC 332 ms
129,392 KB
testcase_33 AC 328 ms
105,548 KB
testcase_34 AC 479 ms
148,932 KB
testcase_35 AC 384 ms
133,576 KB
testcase_36 AC 322 ms
82,536 KB
testcase_37 AC 310 ms
126,068 KB
testcase_38 AC 274 ms
116,568 KB
testcase_39 AC 626 ms
153,640 KB
testcase_40 AC 350 ms
101,588 KB
testcase_41 AC 375 ms
122,212 KB
testcase_42 AC 434 ms
147,656 KB
testcase_43 AC 549 ms
124,124 KB
testcase_44 AC 523 ms
142,488 KB
testcase_45 AC 459 ms
90,536 KB
testcase_46 AC 578 ms
141,288 KB
testcase_47 AC 338 ms
113,064 KB
testcase_48 AC 451 ms
146,596 KB
testcase_49 AC 417 ms
148,036 KB
testcase_50 AC 304 ms
125,556 KB
testcase_51 AC 561 ms
144,860 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 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 MLE -
testcase_93 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

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

m = 2000

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:
      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