結果
問題 | No.854 公平なりんご分配 |
ユーザー | mkawa2 |
提出日時 | 2021-02-26 01:52:42 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,237 ms / 3,153 ms |
コード長 | 2,604 bytes |
コンパイル時間 | 448 ms |
コンパイル使用メモリ | 82,488 KB |
実行使用メモリ | 292,744 KB |
最終ジャッジ日時 | 2024-10-01 18:10:04 |
合計ジャッジ時間 | 26,628 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
54,840 KB |
testcase_01 | AC | 43 ms
55,328 KB |
testcase_02 | AC | 43 ms
56,088 KB |
testcase_03 | AC | 42 ms
55,164 KB |
testcase_04 | AC | 44 ms
56,124 KB |
testcase_05 | AC | 42 ms
55,132 KB |
testcase_06 | AC | 42 ms
55,408 KB |
testcase_07 | AC | 42 ms
56,732 KB |
testcase_08 | AC | 42 ms
55,632 KB |
testcase_09 | AC | 42 ms
55,852 KB |
testcase_10 | AC | 42 ms
55,820 KB |
testcase_11 | AC | 41 ms
55,332 KB |
testcase_12 | AC | 46 ms
62,020 KB |
testcase_13 | AC | 47 ms
61,380 KB |
testcase_14 | AC | 41 ms
55,552 KB |
testcase_15 | AC | 42 ms
56,508 KB |
testcase_16 | AC | 45 ms
61,652 KB |
testcase_17 | AC | 46 ms
61,260 KB |
testcase_18 | AC | 45 ms
61,096 KB |
testcase_19 | AC | 46 ms
61,520 KB |
testcase_20 | AC | 44 ms
55,436 KB |
testcase_21 | AC | 49 ms
62,712 KB |
testcase_22 | AC | 63 ms
69,692 KB |
testcase_23 | AC | 66 ms
70,792 KB |
testcase_24 | AC | 87 ms
77,720 KB |
testcase_25 | AC | 59 ms
68,496 KB |
testcase_26 | AC | 86 ms
77,532 KB |
testcase_27 | AC | 73 ms
75,332 KB |
testcase_28 | AC | 61 ms
68,136 KB |
testcase_29 | AC | 52 ms
64,840 KB |
testcase_30 | AC | 60 ms
68,000 KB |
testcase_31 | AC | 87 ms
77,616 KB |
testcase_32 | AC | 242 ms
146,008 KB |
testcase_33 | AC | 227 ms
93,240 KB |
testcase_34 | AC | 356 ms
163,676 KB |
testcase_35 | AC | 282 ms
146,540 KB |
testcase_36 | AC | 187 ms
79,640 KB |
testcase_37 | AC | 229 ms
129,900 KB |
testcase_38 | AC | 185 ms
98,292 KB |
testcase_39 | AC | 455 ms
166,484 KB |
testcase_40 | AC | 257 ms
91,428 KB |
testcase_41 | AC | 274 ms
129,820 KB |
testcase_42 | AC | 331 ms
160,780 KB |
testcase_43 | AC | 353 ms
138,156 KB |
testcase_44 | AC | 388 ms
158,232 KB |
testcase_45 | AC | 337 ms
85,004 KB |
testcase_46 | AC | 458 ms
160,128 KB |
testcase_47 | AC | 230 ms
96,840 KB |
testcase_48 | AC | 313 ms
147,988 KB |
testcase_49 | AC | 304 ms
153,408 KB |
testcase_50 | AC | 212 ms
134,524 KB |
testcase_51 | AC | 438 ms
154,148 KB |
testcase_52 | AC | 272 ms
94,100 KB |
testcase_53 | AC | 211 ms
93,760 KB |
testcase_54 | AC | 275 ms
96,392 KB |
testcase_55 | AC | 174 ms
93,508 KB |
testcase_56 | AC | 175 ms
94,684 KB |
testcase_57 | AC | 213 ms
91,156 KB |
testcase_58 | AC | 284 ms
83,192 KB |
testcase_59 | AC | 163 ms
89,784 KB |
testcase_60 | AC | 244 ms
92,120 KB |
testcase_61 | AC | 158 ms
80,844 KB |
testcase_62 | AC | 271 ms
89,332 KB |
testcase_63 | AC | 199 ms
89,952 KB |
testcase_64 | AC | 152 ms
82,248 KB |
testcase_65 | AC | 256 ms
158,404 KB |
testcase_66 | AC | 204 ms
86,496 KB |
testcase_67 | AC | 253 ms
99,144 KB |
testcase_68 | AC | 232 ms
87,952 KB |
testcase_69 | AC | 251 ms
153,512 KB |
testcase_70 | AC | 172 ms
91,224 KB |
testcase_71 | AC | 181 ms
92,204 KB |
testcase_72 | AC | 219 ms
79,708 KB |
testcase_73 | AC | 233 ms
142,668 KB |
testcase_74 | AC | 314 ms
151,856 KB |
testcase_75 | AC | 210 ms
92,304 KB |
testcase_76 | AC | 242 ms
138,272 KB |
testcase_77 | AC | 281 ms
160,528 KB |
testcase_78 | AC | 298 ms
88,880 KB |
testcase_79 | AC | 264 ms
100,136 KB |
testcase_80 | AC | 269 ms
132,376 KB |
testcase_81 | AC | 240 ms
134,068 KB |
testcase_82 | AC | 544 ms
292,300 KB |
testcase_83 | AC | 1,166 ms
292,744 KB |
testcase_84 | AC | 1,149 ms
291,636 KB |
testcase_85 | AC | 257 ms
91,112 KB |
testcase_86 | AC | 103 ms
90,560 KB |
testcase_87 | AC | 538 ms
292,336 KB |
testcase_88 | AC | 539 ms
292,688 KB |
testcase_89 | AC | 546 ms
292,024 KB |
testcase_90 | AC | 530 ms
292,592 KB |
testcase_91 | AC | 559 ms
291,828 KB |
testcase_92 | AC | 1,237 ms
292,228 KB |
testcase_93 | AC | 1,215 ms
292,284 KB |
ソースコード
import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.buffer.readline()) def FI(): return float(sys.stdin.buffer.readline()) def MI(): return map(int, sys.stdin.buffer.readline().split()) def MF(): return map(float, sys.stdin.buffer.readline().split()) def MI1(): return map(int1, sys.stdin.buffer.readline().split()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LI1(): return list(map(int1, sys.stdin.buffer.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def BI(): return sys.stdin.buffer.readline().rstrip() def SI(): return sys.stdin.buffer.readline().rstrip().decode() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] inf = 10**16 # md = 998244353 md = 10**9+7 class Sieve: def __init__(self, n): self.plist = [2] # n以下の素数のリスト min_prime_factor = [2, 0]*(n//2+5) for x in range(3, n+1, 2): if min_prime_factor[x] == 0: min_prime_factor[x] = x self.plist.append(x) if x**2 > n: continue for y in range(x**2, n+5, 2*x): if min_prime_factor[y] == 0: min_prime_factor[y] = x self.min_prime_factor = min_prime_factor def isprime(self, x): return self.min_prime_factor[x] == x # これが素因数分解(prime factorization) def pfct(self, x): pp, ee = [], [] while x > 1: mpf = self.min_prime_factor[x] if pp and mpf == pp[-1]: ee[-1] += 1 else: pp.append(mpf) ee.append(1) x //= mpf return [(p, e) for p, e in zip(pp, ee)] from collections import defaultdict from array import array sv = Sieve(2005) n = II() aa = LI() df = lambda: array("I", [0]*(n+1)) cs = defaultdict(df) for i, a in enumerate(aa): if a == 0: cs[0][i+1] = 1 else: pe = sv.pfct(a) for p, e in pe: cs[p][i+1] = e for k, v in cs.items(): for i in range(n): v[i+1] += v[i] # print(cs) def ok(a): if a == 1: return True if cs[0][r]-cs[0][l]: return True for p in cs.keys(): if p == 0: continue e = 0 while a%p == 0: a //= p e += 1 if e and cs[p][r]-cs[p][l] < e: return False if a != 1: return False return True for _ in range(II()): a, l, r = MI() l -= 1 print("Yes" if ok(a) else "NO")