結果
問題 |
No.732 3PrimeCounting
|
ユーザー |
![]() |
提出日時 | 2018-10-02 08:20:07 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,770 ms / 3,000 ms |
コード長 | 369 bytes |
コンパイル時間 | 225 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 45,484 KB |
最終ジャッジ日時 | 2024-10-12 10:01:37 |
合計ジャッジ時間 | 65,478 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 89 |
ソースコード
import numpy as np n = int(input()) sieve = np.ones(n*3+1, dtype=bool) for i in range(2, int((n*3)**0.5)+2): if sieve[i]: sieve[i+i::i] = False ps1 = np.where(sieve)[0][2:] ps2 = ps1[ps1 <= n] cnt = np.zeros(n*3+1, dtype='int64') res = 0 for i in reversed(range(len(ps2))): a = ps2[i] res += cnt[ps1 - a].sum() cnt[ps2[i+1:] + a] += 1 print(res)