結果
| 問題 |
No.371 ぼく悪いプライムじゃないよ
|
| コンテスト | |
| ユーザー |
Nachia
|
| 提出日時 | 2020-09-27 20:51:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 757 bytes |
| コンパイル時間 | 1,475 ms |
| コンパイル使用メモリ | 167,652 KB |
| 実行使用メモリ | 12,432 KB |
| 最終ジャッジ日時 | 2024-06-30 12:54:38 |
| 合計ジャッジ時間 | 3,970 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 26 WA * 16 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)
const ULL Z = 1000000;
bool sieve[Z + 1];
ULL bull[Z + 1]; ULL offset;
int main() {
ULL L, R; cin >> L >> R; R--;
offset = max(Z, R) - Z;
rep(i, Z + 1) bull[i] = i;
sieve[0] = sieve[1] = true;
for (ULL i = 2; i < Z; i++) {
if (sieve[i]) continue;
if (i <= 1000) for (ULL j = i * i; j < Z; j += i) sieve[j] = true;
for (ULL j = i - (offset + i - 1) % i - 1; j <= Z; j += i) bull[j] = min(bull[j], i);
}
ULL ans = 0, val = 0;
for (ULL i = max(offset, L) - offset; i <= R - offset; i++)
if (bull[i] != i) if (val <= bull[i]) {
val = bull[i]; ans = offset + i;
}
cout << ans << endl;
return 0;
}
Nachia