結果
問題 |
No.407 鴨等素数間隔列の数え上げ
|
ユーザー |
|
提出日時 | 2020-05-17 19:42:24 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 578 bytes |
コンパイル時間 | 4,001 ms |
コンパイル使用メモリ | 127,936 KB |
最終ジャッジ日時 | 2025-01-10 12:45:21 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 15 RE * 16 |
ソースコード
#include <iostream> #include <vector> #include <iomanip> #include <algorithm> #include <cmath> using namespace std; using ll = long long; ll n, l; int main() { cin >> n >> l; vector<ll> prime; vector<bool> is_prime(1000010, true); for (ll i = 2; i < l; ++i) { if (is_prime[i]) { prime.push_back(i); for (ll j = i + i; j < l; j += i) { is_prime[j] = false; } } } ll ans = 0; for (int p : prime) { ll all = p * ~-n; if (all <= l) { ans += l - all + 1; } } cout << ans << endl; return 0; }