結果
問題 | No.854 公平なりんご分配 |
ユーザー | mkawa2 |
提出日時 | 2021-02-26 01:45:47 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 2,568 bytes |
コンパイル時間 | 373 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 319,744 KB |
最終ジャッジ日時 | 2024-10-01 18:04:11 |
合計ジャッジ時間 | 25,800 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 48 ms
54,016 KB |
testcase_01 | AC | 51 ms
54,016 KB |
testcase_02 | AC | 48 ms
54,016 KB |
testcase_03 | AC | 48 ms
54,144 KB |
testcase_04 | AC | 48 ms
54,016 KB |
testcase_05 | AC | 50 ms
54,016 KB |
testcase_06 | AC | 48 ms
53,888 KB |
testcase_07 | AC | 48 ms
54,016 KB |
testcase_08 | AC | 50 ms
53,888 KB |
testcase_09 | AC | 45 ms
54,016 KB |
testcase_10 | AC | 43 ms
54,400 KB |
testcase_11 | AC | 43 ms
54,016 KB |
testcase_12 | AC | 49 ms
60,032 KB |
testcase_13 | AC | 48 ms
60,032 KB |
testcase_14 | AC | 43 ms
54,016 KB |
testcase_15 | AC | 44 ms
54,016 KB |
testcase_16 | AC | 48 ms
60,032 KB |
testcase_17 | AC | 49 ms
59,776 KB |
testcase_18 | AC | 49 ms
59,776 KB |
testcase_19 | AC | 48 ms
59,904 KB |
testcase_20 | AC | 46 ms
54,656 KB |
testcase_21 | AC | 50 ms
59,776 KB |
testcase_22 | AC | 69 ms
67,072 KB |
testcase_23 | AC | 73 ms
68,480 KB |
testcase_24 | AC | 94 ms
77,824 KB |
testcase_25 | AC | 63 ms
65,408 KB |
testcase_26 | AC | 97 ms
77,440 KB |
testcase_27 | AC | 81 ms
72,960 KB |
testcase_28 | AC | 69 ms
66,304 KB |
testcase_29 | AC | 56 ms
62,464 KB |
testcase_30 | AC | 63 ms
65,536 KB |
testcase_31 | AC | 98 ms
77,312 KB |
testcase_32 | AC | 231 ms
127,488 KB |
testcase_33 | AC | 241 ms
104,448 KB |
testcase_34 | AC | 336 ms
147,456 KB |
testcase_35 | AC | 277 ms
132,608 KB |
testcase_36 | AC | 190 ms
80,384 KB |
testcase_37 | AC | 231 ms
125,056 KB |
testcase_38 | AC | 198 ms
115,712 KB |
testcase_39 | AC | 426 ms
151,808 KB |
testcase_40 | AC | 254 ms
101,376 KB |
testcase_41 | AC | 263 ms
121,088 KB |
testcase_42 | AC | 315 ms
146,432 KB |
testcase_43 | AC | 331 ms
123,648 KB |
testcase_44 | AC | 357 ms
141,568 KB |
testcase_45 | AC | 314 ms
89,088 KB |
testcase_46 | AC | 413 ms
140,672 KB |
testcase_47 | AC | 241 ms
111,872 KB |
testcase_48 | AC | 293 ms
145,664 KB |
testcase_49 | AC | 302 ms
147,200 KB |
testcase_50 | AC | 207 ms
124,288 KB |
testcase_51 | AC | 401 ms
143,488 KB |
testcase_52 | AC | 277 ms
106,112 KB |
testcase_53 | AC | 214 ms
105,856 KB |
testcase_54 | AC | 276 ms
111,232 KB |
testcase_55 | AC | 197 ms
105,984 KB |
testcase_56 | AC | 182 ms
107,008 KB |
testcase_57 | AC | 209 ms
100,864 KB |
testcase_58 | AC | 274 ms
86,656 KB |
testcase_59 | AC | 174 ms
97,920 KB |
testcase_60 | AC | 237 ms
101,376 KB |
testcase_61 | AC | 157 ms
80,896 KB |
testcase_62 | AC | 279 ms
97,792 KB |
testcase_63 | AC | 216 ms
98,048 KB |
testcase_64 | AC | 155 ms
84,992 KB |
testcase_65 | AC | 238 ms
137,216 KB |
testcase_66 | AC | 201 ms
92,288 KB |
testcase_67 | AC | 249 ms
116,352 KB |
testcase_68 | AC | 242 ms
94,080 KB |
testcase_69 | AC | 235 ms
151,424 KB |
testcase_70 | AC | 173 ms
100,608 KB |
testcase_71 | AC | 182 ms
103,296 KB |
testcase_72 | AC | 210 ms
80,128 KB |
testcase_73 | AC | 211 ms
125,184 KB |
testcase_74 | AC | 286 ms
137,216 KB |
testcase_75 | AC | 216 ms
103,168 KB |
testcase_76 | AC | 229 ms
122,880 KB |
testcase_77 | AC | 272 ms
144,640 KB |
testcase_78 | AC | 293 ms
95,872 KB |
testcase_79 | AC | 284 ms
117,376 KB |
testcase_80 | AC | 263 ms
119,936 KB |
testcase_81 | AC | 225 ms
121,344 KB |
testcase_82 | MLE | - |
testcase_83 | MLE | - |
testcase_84 | MLE | - |
testcase_85 | AC | 270 ms
90,240 KB |
testcase_86 | AC | 119 ms
89,984 KB |
testcase_87 | MLE | - |
testcase_88 | MLE | - |
testcase_89 | MLE | - |
testcase_90 | MLE | - |
testcase_91 | MLE | - |
testcase_92 | MLE | - |
testcase_93 | MLE | - |
ソースコード
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 sv = Sieve(2005) n = II() aa = LI() df = lambda: [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")