結果
| 問題 |
No.407 鴨等素数間隔列の数え上げ
|
| コンテスト | |
| ユーザー |
kpinkcat
|
| 提出日時 | 2023-12-11 02:47:00 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 723 bytes |
| コンパイル時間 | 982 ms |
| コンパイル使用メモリ | 104,640 KB |
| 最終ジャッジ日時 | 2025-02-18 10:15:26 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | TLE * 5 |
| other | TLE * 31 |
ソースコード
#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()
{
ll n, l, max = 0, MAX = 1e7+1;
ll ans = 0;
cin >> n >> l;
vector<ll> p(MAX, 1);
p[0] = 0;
p[1] = 0;
for (int i = 2; i < MAX; i++){
for (int j = i*2; j < MAX; j += i){
p[j] = 0;
}
}
max = 2*(n-1);
if ((l - max + 1) > 0) ans += (l - max + 1);
for (ll i = 3; i*(n-1) < MAX; i+=2){
if (p[i]) {
max = i*(n-1);
if ((l - max + 1) > 0) ans += (l - max + 1);
}
}
cout << ans << endl;
}
kpinkcat