結果
問題 |
No.407 鴨等素数間隔列の数え上げ
|
ユーザー |
|
提出日時 | 2016-11-15 00:41:53 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 545 bytes |
コンパイル時間 | 829 ms |
コンパイル使用メモリ | 62,456 KB |
実行使用メモリ | 14,336 KB |
最終ジャッジ日時 | 2024-11-26 01:26:57 |
合計ジャッジ時間 | 3,862 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 WA * 1 |
other | AC * 16 WA * 15 |
ソースコード
#include "iostream" #include "list" #include "math.h" using namespace std; int N, L; list <int>P; long long int ans; bool flag; int main() { cin >> N >> L; P.push_back(2); for (int i = 3; i <= L/(N-1); i+=2) { flag = true; for (auto j = P.begin()++; j != P.end()&&(*j)<sqrt(i); ++j) { if (i % (*j) == 0) { flag = false; break; } } if (flag) { P.push_back(i); } } for (auto i = P.begin(); i != P.end(); ++i) { if (L - (N - 1)*(*i) < 0)break; ans += L - (N - 1)*(*i) + 1; } cout << ans << "\n"; return 0; }