結果
問題 |
No.407 鴨等素数間隔列の数え上げ
|
ユーザー |
|
提出日時 | 2025-10-13 09:07:47 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 115 ms / 1,000 ms |
コード長 | 549 bytes |
コンパイル時間 | 2,674 ms |
コンパイル使用メモリ | 278,428 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-10-13 09:07:56 |
合計ジャッジ時間 | 7,939 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i) int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int N, L; cin >> N >> L; int maxi = 10000100; vector<bool> isPrime(maxi, true); isPrime[0] = isPrime[1] = false; rep(p, 2, maxi) if (isPrime[p]) { for (int q = p*2; q < maxi; q += p) isPrime[q] = false; } ll ans = 0; rep(p, 2, maxi) if (isPrime[p]) { if (L < p*(N - 1)) break; ans += L - p*(N - 1) + 1; } cout << ans << '\n'; }