結果
| 問題 |
No.407 鴨等素数間隔列の数え上げ
|
| コンテスト | |
| ユーザー |
kpinkcat
|
| 提出日時 | 2023-12-11 04:11:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 838 bytes |
| コンパイル時間 | 975 ms |
| コンパイル使用メモリ | 106,700 KB |
| 最終ジャッジ日時 | 2025-02-18 10:18:12 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 WA * 1 |
| other | AC * 27 WA * 4 |
ソースコード
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
#include<set>
#include<bitset>
#include<math.h>
#include<map>
#include<queue>
#include<iomanip>
using namespace std;
using ll = long long;
int main()
{
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
int n, l, max1 = 0;
ll ans = 0;
cin >> n >> l;
int MAX = max(1, l/(n-1));
vector<int> p(MAX+1, 1), primes;
p[0] = 0;
p[1] = 0;
for (int i = 2; i <= MAX; i++){
if (p[i]) primes.push_back(i);
for (int j = i*2; j <= MAX; j += i){
p[j] = 0;
}
}
if (!primes.size()) primes.push_back(MAX);
for (int i = 0; primes[i]*(n-1) <= l && i < primes.size(); i++){
max1 = primes[i]*(n-1);
if ((l - max1 + 1)>0) ans += (l - max1 + 1);
}
cout << ans << endl;
}
kpinkcat