結果
| 問題 |
No.407 鴨等素数間隔列の数え上げ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-03 14:45:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 45 ms / 1,000 ms |
| コード長 | 559 bytes |
| コンパイル時間 | 566 ms |
| コンパイル使用メモリ | 69,896 KB |
| 実行使用メモリ | 10,204 KB |
| 最終ジャッジ日時 | 2024-06-30 09:21:35 |
| 合計ジャッジ時間 | 3,334 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 31 |
ソースコード
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define max 5000000
bool np[max] = {};
vector<int> p;
int main(){
np[0] = np[1] = true;
for(int i = 2; i < max; i++){
if(!np[i]){
p.push_back(i);
for(int j = i+i; j < max; j += i) np[j] = true;
}
}
ll n, l;
cin >> n >> l;
ll ans = 0;
double upper = (double)l/(n-1);
for(int prime : p){
if(prime > upper) break;
ans += l-(n-1)*prime+1;
}
cout << ans << endl;
return 0;
}