結果
| 問題 |
No.407 鴨等素数間隔列の数え上げ
|
| コンテスト | |
| ユーザー |
はまやんはまやん
|
| 提出日時 | 2016-08-07 12:05:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 54 ms / 1,000 ms |
| コード長 | 680 bytes |
| コンパイル時間 | 1,731 ms |
| コンパイル使用メモリ | 171,924 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-15 22:54:30 |
| 合計ジャッジ時間 | 3,214 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 31 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
vector<bool> primes;
void make_primes(int n)
{
primes.resize(n + 1, true);
primes[0] = primes[1] = false;
rep(i, 2, sqrt(n))
{
if (primes[i])
{
for (int j = 0; i * (j + 2) < n; j++)
primes[i * (j + 2)] = false;
}
}
}
//-----------------------------------------------------------------
typedef long long ll;
int N, L;
//-----------------------------------------------------------------
int main() {
cin >> N >> L;
make_primes(L);
ll ans = 0;
rep(i, 0, L) if(primes[i]) {
int _max = i * (N - 1);
if (L < _max) break;
ans += L - _max + 1;
}
cout << ans << endl;
}
はまやんはまやん