結果
問題 | No.732 3PrimeCounting |
ユーザー | shotoyoo |
提出日時 | 2021-05-26 00:21:34 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 771 ms / 3,000 ms |
コード長 | 1,505 bytes |
コンパイル時間 | 330 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 84,500 KB |
最終ジャッジ日時 | 2024-10-14 15:11:12 |
合計ジャッジ時間 | 50,202 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 471 ms
44,584 KB |
testcase_01 | AC | 472 ms
44,200 KB |
testcase_02 | AC | 481 ms
44,580 KB |
testcase_03 | AC | 455 ms
44,452 KB |
testcase_04 | AC | 459 ms
44,456 KB |
testcase_05 | AC | 459 ms
44,200 KB |
testcase_06 | AC | 468 ms
44,460 KB |
testcase_07 | AC | 461 ms
44,236 KB |
testcase_08 | AC | 455 ms
44,712 KB |
testcase_09 | AC | 459 ms
44,452 KB |
testcase_10 | AC | 464 ms
44,196 KB |
testcase_11 | AC | 461 ms
44,200 KB |
testcase_12 | AC | 468 ms
44,328 KB |
testcase_13 | AC | 463 ms
44,464 KB |
testcase_14 | AC | 464 ms
44,200 KB |
testcase_15 | AC | 466 ms
44,468 KB |
testcase_16 | AC | 461 ms
44,208 KB |
testcase_17 | AC | 457 ms
44,584 KB |
testcase_18 | AC | 459 ms
44,200 KB |
testcase_19 | AC | 462 ms
44,588 KB |
testcase_20 | AC | 457 ms
44,456 KB |
testcase_21 | AC | 459 ms
44,196 KB |
testcase_22 | AC | 472 ms
44,448 KB |
testcase_23 | AC | 462 ms
44,204 KB |
testcase_24 | AC | 459 ms
44,712 KB |
testcase_25 | AC | 472 ms
44,208 KB |
testcase_26 | AC | 462 ms
44,456 KB |
testcase_27 | AC | 468 ms
44,456 KB |
testcase_28 | AC | 459 ms
44,320 KB |
testcase_29 | AC | 465 ms
44,460 KB |
testcase_30 | AC | 461 ms
44,588 KB |
testcase_31 | AC | 460 ms
44,580 KB |
testcase_32 | AC | 468 ms
44,204 KB |
testcase_33 | AC | 476 ms
44,456 KB |
testcase_34 | AC | 470 ms
44,328 KB |
testcase_35 | AC | 462 ms
44,580 KB |
testcase_36 | AC | 463 ms
44,072 KB |
testcase_37 | AC | 455 ms
44,076 KB |
testcase_38 | AC | 459 ms
44,584 KB |
testcase_39 | AC | 464 ms
44,456 KB |
testcase_40 | AC | 469 ms
44,584 KB |
testcase_41 | AC | 463 ms
44,588 KB |
testcase_42 | AC | 472 ms
44,580 KB |
testcase_43 | AC | 473 ms
44,296 KB |
testcase_44 | AC | 463 ms
44,332 KB |
testcase_45 | AC | 474 ms
44,456 KB |
testcase_46 | AC | 458 ms
44,072 KB |
testcase_47 | AC | 481 ms
44,580 KB |
testcase_48 | AC | 464 ms
44,456 KB |
testcase_49 | AC | 471 ms
44,452 KB |
testcase_50 | AC | 475 ms
44,716 KB |
testcase_51 | AC | 469 ms
44,332 KB |
testcase_52 | AC | 468 ms
44,204 KB |
testcase_53 | AC | 557 ms
45,092 KB |
testcase_54 | AC | 601 ms
63,168 KB |
testcase_55 | AC | 612 ms
62,972 KB |
testcase_56 | AC | 606 ms
62,552 KB |
testcase_57 | AC | 500 ms
46,484 KB |
testcase_58 | AC | 498 ms
46,740 KB |
testcase_59 | AC | 485 ms
44,872 KB |
testcase_60 | AC | 532 ms
51,608 KB |
testcase_61 | AC | 528 ms
51,736 KB |
testcase_62 | AC | 628 ms
64,856 KB |
testcase_63 | AC | 563 ms
53,028 KB |
testcase_64 | AC | 538 ms
52,376 KB |
testcase_65 | AC | 542 ms
52,000 KB |
testcase_66 | AC | 466 ms
44,204 KB |
testcase_67 | AC | 470 ms
44,580 KB |
testcase_68 | AC | 627 ms
64,512 KB |
testcase_69 | AC | 617 ms
63,140 KB |
testcase_70 | AC | 601 ms
62,904 KB |
testcase_71 | AC | 602 ms
63,452 KB |
testcase_72 | AC | 552 ms
52,380 KB |
testcase_73 | AC | 658 ms
66,408 KB |
testcase_74 | AC | 666 ms
66,424 KB |
testcase_75 | AC | 471 ms
44,336 KB |
testcase_76 | AC | 605 ms
63,336 KB |
testcase_77 | AC | 504 ms
46,736 KB |
testcase_78 | AC | 656 ms
65,632 KB |
testcase_79 | AC | 620 ms
63,808 KB |
testcase_80 | AC | 647 ms
66,032 KB |
testcase_81 | AC | 645 ms
62,568 KB |
testcase_82 | AC | 558 ms
44,368 KB |
testcase_83 | AC | 511 ms
46,228 KB |
testcase_84 | AC | 527 ms
50,208 KB |
testcase_85 | AC | 600 ms
63,808 KB |
testcase_86 | AC | 679 ms
65,512 KB |
testcase_87 | AC | 771 ms
83,128 KB |
testcase_88 | AC | 746 ms
84,500 KB |
ソースコード
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(2*10**5+10) write = lambda x: sys.stdout.write(x+"\n") debug = lambda x: sys.stderr.write(x+"\n") writef = lambda x: print("{:.12f}".format(x)) def hurui(n): """線形篩 pl: 素数のリスト mpf: iを割り切る最小の素因数 """ pl = [] mpf = [None]*(n+1) for d in range(2,n+1): if mpf[d] is None: mpf[d] = d pl.append(d) for p in pl: if p*d>n or p>mpf[d]: break mpf[p*d] = p return pl, mpf # FFT import numpy as np TYPE = np.int32 M = 998244353 def fft(a,b): l = len(a) + len(b) - 1 l = 1<<((l-1).bit_length()) a = np.array(a) c = np.fft.irfft((np.fft.rfft(a,l))*(np.fft.rfft(b,l)),l) c = np.rint(c).astype(TYPE) s = np.where(c>0)[0].max() return c[:s+1] def fft_large(a,b): d = 30000 a1, a2 = np.divmod(a,d) b1, b2 = np.divmod(b,d) aa = fft(a1,b1) % M bb = fft(a2,b2) % M cc = (fft(a1+a2, b1+b2) - (aa+bb)) % M h = (((aa*d)%M)*d + cc*d + bb) % M return h n = int(input()) pl, _ = hurui(3*n) ps = [v for v in pl if v<=n] ok = [0]*(n+1) ok2 = [0]*(2*n+1) for p in ps: ok[p] = 1 ok2[2*p] = 1 mask = [0]*(3*n+1) for p in pl: mask[p] = 1 b2 = fft(ok, ok) b3 = fft(b2, ok) b22 = fft(ok, ok2) mask = np.array(mask, dtype=bool) val1 = b3[mask[:b3.shape[0]]].sum() val2 = b22[mask[:b22.shape[0]]].sum() ans = (val1-val2*3)//6 print(ans)