結果
| 問題 |
No.407 鴨等素数間隔列の数え上げ
|
| コンテスト | |
| ユーザー |
dnish
|
| 提出日時 | 2017-07-10 22:15:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 50 ms / 1,000 ms |
| コード長 | 547 bytes |
| コンパイル時間 | 1,672 ms |
| コンパイル使用メモリ | 174,388 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-07 07:15:31 |
| 合計ジャッジ時間 | 3,023 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int) N;i++)
#define p(s) cout<<(s)<<endl
typedef long long ll;
using namespace std;
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;
}
}
}
int main() {
int N,L;
cin>>N>>L;
make_primes(L);
ll ans=0;
REP(i,0,L) if(primes[i]){
int mx=i*(N-1);
if(L<mx) break;
ans+=L-mx+1;
}
p(ans);
return 0;
}
dnish