結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー keikei
提出日時 2016-10-09 17:40:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,090 bytes
コンパイル時間 872 ms
コンパイル使用メモリ 77,240 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 18:31:07
合計ジャッジ時間 2,511 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 WA -
testcase_03 AC 1 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,944 KB
testcase_06 WA -
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 WA -
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 WA -
testcase_15 AC 2 ms
6,940 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 WA -
testcase_25 AC 14 ms
6,940 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 13 ms
6,944 KB
testcase_29 AC 14 ms
6,944 KB
testcase_30 AC 14 ms
6,944 KB
testcase_31 AC 14 ms
6,944 KB
testcase_32 AC 14 ms
6,940 KB
testcase_33 AC 14 ms
6,944 KB
testcase_34 AC 12 ms
6,940 KB
testcase_35 AC 13 ms
6,940 KB
testcase_36 AC 7 ms
6,944 KB
testcase_37 AC 14 ms
6,944 KB
testcase_38 AC 12 ms
6,940 KB
testcase_39 AC 15 ms
6,944 KB
testcase_40 AC 14 ms
6,940 KB
testcase_41 AC 13 ms
6,940 KB
testcase_42 AC 12 ms
6,940 KB
testcase_43 AC 15 ms
6,940 KB
testcase_44 AC 9 ms
6,944 KB
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;


long long min_prime_check(long long x) {
	if (x % 2 == 0) return 2;
	for (long long i = 3; i*i <= x; i += 2) {
		if (x % i == 0)return i;
	}
	return x;
}


bool prime_check(long long x) {
	if (x % 2 == 0) return false;
	for (long long i = 3; i*i <= x; i += 2) {
		if (x % i == 0)return false;
	}
	return true;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);

	long long L, H, Ans; cin >> L >> H;
	vector<long long> p;
//	cout << sqrt(L);
	/* initialize*/
	long long Sq = (int)sqrt(H);
	for (long long i = Sq; i >= 3; i--) {
		if (prime_check(i)) {
			p.push_back(i);
		}
	}

	/* solve */
	bool f1, f2;
	long long l, h;
	for (long long i = 0; i < p.size(); i++) {
		if (L%p[i] == 0) { f1 = true; }
		else { f1 = false; }
		if (H%p[i] == 0) { f2 = true; }
		else { f2 = false; }
		l = L / p[i]; h = H / p[i];

		for (long long j = h; j > l; j--) {
			if (min_prime_check(j) >= p[i]) {
				if (L <= j * p[i] && H >= j*p[i]) {
					cout << j*p[i] << endl; return 0;
				}
			}
		}
	}
}
0