結果
問題 | No.1262 グラフを作ろう! |
ユーザー | mkawa2 |
提出日時 | 2024-06-20 21:54:50 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 840 ms / 3,000 ms |
コード長 | 2,101 bytes |
コンパイル時間 | 290 ms |
コンパイル使用メモリ | 82,824 KB |
実行使用メモリ | 255,508 KB |
最終ジャッジ日時 | 2024-06-20 21:55:51 |
合計ジャッジ時間 | 57,827 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 691 ms
222,960 KB |
testcase_01 | AC | 452 ms
184,776 KB |
testcase_02 | AC | 696 ms
222,568 KB |
testcase_03 | AC | 656 ms
229,292 KB |
testcase_04 | AC | 125 ms
94,712 KB |
testcase_05 | AC | 404 ms
162,724 KB |
testcase_06 | AC | 109 ms
91,024 KB |
testcase_07 | AC | 146 ms
101,584 KB |
testcase_08 | AC | 467 ms
178,116 KB |
testcase_09 | AC | 487 ms
165,632 KB |
testcase_10 | AC | 362 ms
163,068 KB |
testcase_11 | AC | 476 ms
187,788 KB |
testcase_12 | AC | 658 ms
207,256 KB |
testcase_13 | AC | 704 ms
229,556 KB |
testcase_14 | AC | 337 ms
143,480 KB |
testcase_15 | AC | 412 ms
187,624 KB |
testcase_16 | AC | 509 ms
174,344 KB |
testcase_17 | AC | 472 ms
174,636 KB |
testcase_18 | AC | 715 ms
222,840 KB |
testcase_19 | AC | 151 ms
100,500 KB |
testcase_20 | AC | 295 ms
124,136 KB |
testcase_21 | AC | 771 ms
247,172 KB |
testcase_22 | AC | 107 ms
91,180 KB |
testcase_23 | AC | 437 ms
189,308 KB |
testcase_24 | AC | 490 ms
174,528 KB |
testcase_25 | AC | 142 ms
98,452 KB |
testcase_26 | AC | 188 ms
110,712 KB |
testcase_27 | AC | 328 ms
140,964 KB |
testcase_28 | AC | 290 ms
131,300 KB |
testcase_29 | AC | 209 ms
108,180 KB |
testcase_30 | AC | 286 ms
125,388 KB |
testcase_31 | AC | 722 ms
246,892 KB |
testcase_32 | AC | 457 ms
178,116 KB |
testcase_33 | AC | 249 ms
124,608 KB |
testcase_34 | AC | 385 ms
154,316 KB |
testcase_35 | AC | 622 ms
207,356 KB |
testcase_36 | AC | 286 ms
138,944 KB |
testcase_37 | AC | 735 ms
230,088 KB |
testcase_38 | AC | 400 ms
166,440 KB |
testcase_39 | AC | 458 ms
188,876 KB |
testcase_40 | AC | 413 ms
165,144 KB |
testcase_41 | AC | 247 ms
111,780 KB |
testcase_42 | AC | 652 ms
186,188 KB |
testcase_43 | AC | 399 ms
144,180 KB |
testcase_44 | AC | 429 ms
166,008 KB |
testcase_45 | AC | 584 ms
165,688 KB |
testcase_46 | AC | 208 ms
110,700 KB |
testcase_47 | AC | 539 ms
181,032 KB |
testcase_48 | AC | 603 ms
164,808 KB |
testcase_49 | AC | 753 ms
228,612 KB |
testcase_50 | AC | 599 ms
184,116 KB |
testcase_51 | AC | 543 ms
185,656 KB |
testcase_52 | AC | 228 ms
110,624 KB |
testcase_53 | AC | 175 ms
108,356 KB |
testcase_54 | AC | 741 ms
234,716 KB |
testcase_55 | AC | 516 ms
165,172 KB |
testcase_56 | AC | 253 ms
112,064 KB |
testcase_57 | AC | 789 ms
251,268 KB |
testcase_58 | AC | 647 ms
222,608 KB |
testcase_59 | AC | 263 ms
111,352 KB |
testcase_60 | AC | 761 ms
228,992 KB |
testcase_61 | AC | 369 ms
151,308 KB |
testcase_62 | AC | 668 ms
226,972 KB |
testcase_63 | AC | 730 ms
251,572 KB |
testcase_64 | AC | 450 ms
174,752 KB |
testcase_65 | AC | 216 ms
106,172 KB |
testcase_66 | AC | 387 ms
153,128 KB |
testcase_67 | AC | 274 ms
116,776 KB |
testcase_68 | AC | 172 ms
106,080 KB |
testcase_69 | AC | 297 ms
125,100 KB |
testcase_70 | AC | 623 ms
163,880 KB |
testcase_71 | AC | 585 ms
174,804 KB |
testcase_72 | AC | 659 ms
185,920 KB |
testcase_73 | AC | 840 ms
255,164 KB |
testcase_74 | AC | 598 ms
228,532 KB |
testcase_75 | AC | 649 ms
184,356 KB |
testcase_76 | AC | 528 ms
174,424 KB |
testcase_77 | AC | 751 ms
205,944 KB |
testcase_78 | AC | 561 ms
166,480 KB |
testcase_79 | AC | 759 ms
222,380 KB |
testcase_80 | AC | 511 ms
174,348 KB |
testcase_81 | AC | 620 ms
206,156 KB |
testcase_82 | AC | 742 ms
255,140 KB |
testcase_83 | AC | 514 ms
174,160 KB |
testcase_84 | AC | 458 ms
174,672 KB |
testcase_85 | AC | 816 ms
234,652 KB |
testcase_86 | AC | 647 ms
200,240 KB |
testcase_87 | AC | 714 ms
228,068 KB |
testcase_88 | AC | 610 ms
206,200 KB |
testcase_89 | AC | 467 ms
177,924 KB |
testcase_90 | AC | 375 ms
254,936 KB |
testcase_91 | AC | 410 ms
255,508 KB |
testcase_92 | AC | 389 ms
254,772 KB |
testcase_93 | AC | 647 ms
214,956 KB |
testcase_94 | AC | 807 ms
254,688 KB |
testcase_95 | AC | 606 ms
252,364 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = -1-(-1 << 31) inf = -1-(-1 << 62) # md = 10**9+7 md = 998244353 class Sieve: def __init__(self, n): self.plist = [2] min_prime_factor = [2, 0]*(n//2+1) 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+1, 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 def pf(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 pp, ee # unsorted def factor(self, a): ff = [1] pp, ee = self.pf(a) for p, e in zip(pp, ee): ff, gg = [], ff w = p for _ in range(e): for f in gg: ff.append(f*w) w *= p ff += gg return ff, pp sv=Sieve(10**6) n,m=LI() aa=LI() ans=0 for a in aa: ans-=a pp,ee=sv.pf(a) for p,e in zip(pp,ee): a=a*((p-1)*(e+1)+1)//p ans+=a print(ans)