結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー 👑 NachiaNachia
提出日時 2020-09-27 20:51:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 757 bytes
コンパイル時間 1,452 ms
コンパイル使用メモリ 164,668 KB
実行使用メモリ 12,464 KB
最終ジャッジ日時 2023-09-13 02:14:53
合計ジャッジ時間 4,413 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
12,104 KB
testcase_01 WA -
testcase_02 AC 17 ms
12,448 KB
testcase_03 AC 17 ms
12,124 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 18 ms
12,156 KB
testcase_08 AC 18 ms
12,104 KB
testcase_09 AC 18 ms
12,104 KB
testcase_10 AC 17 ms
12,180 KB
testcase_11 AC 17 ms
12,448 KB
testcase_12 AC 18 ms
12,168 KB
testcase_13 WA -
testcase_14 AC 19 ms
12,104 KB
testcase_15 AC 18 ms
12,116 KB
testcase_16 AC 18 ms
12,124 KB
testcase_17 AC 17 ms
12,128 KB
testcase_18 AC 17 ms
12,172 KB
testcase_19 AC 18 ms
12,100 KB
testcase_20 AC 21 ms
12,136 KB
testcase_21 AC 18 ms
12,132 KB
testcase_22 AC 21 ms
12,184 KB
testcase_23 AC 18 ms
12,156 KB
testcase_24 AC 19 ms
12,116 KB
testcase_25 AC 21 ms
12,100 KB
testcase_26 AC 18 ms
12,240 KB
testcase_27 AC 18 ms
12,160 KB
testcase_28 AC 19 ms
12,112 KB
testcase_29 AC 19 ms
12,328 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 19 ms
12,164 KB
testcase_42 AC 20 ms
12,176 KB
testcase_43 AC 18 ms
12,120 KB
testcase_44 AC 18 ms
12,116 KB
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0