結果
| 問題 |
No.407 鴨等素数間隔列の数え上げ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-08-20 19:56:45 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 132 ms / 1,000 ms |
| コード長 | 628 bytes |
| コンパイル時間 | 844 ms |
| コンパイル使用メモリ | 74,848 KB |
| 最終ジャッジ日時 | 2025-01-31 02:08:01 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 31 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
struct SieveEratos{
vector<bool> t;
vector<int> primes;
SieveEratos(int n):t(n+1,true){
t[0] = t[1] = false;
for(int i = 2; n >= i; i++){
if(t[i]){
primes.emplace_back(i);
for(int j = i+i; n >= j; j+=i){
t[j] = false;
}
}
}
}
bool operator[](int x){return t[x];}
};
int main(){
long long n,l;cin>>n>>l;
SieveEratos P(l+1);
long long ans = 0;
for(long long i = 2; l >= i; i++){
if(P[i]){
ans += max(0LL,l-((n-1)*i)+1);
}
}
cout << ans << endl;
}