結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー airisairis
提出日時 2016-05-25 00:47:37
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,338 bytes
コンパイル時間 1,464 ms
コンパイル使用メモリ 161,128 KB
実行使用メモリ 10,652 KB
最終ジャッジ日時 2024-04-16 12:26:03
合計ジャッジ時間 4,609 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;


int prime[100005];

ll L, H;
ll ans;
vector<ll> p;

void sieve_of_eratosthenes(int *a, int n) {
	fill(a, a+n, 1);
	a[0] = a[1] = 0;
	for (int i = 2; i * i < n; i++) {
		if (a[i] == 0) continue;
		for (int j = i + i; j < n; j += i) {
			a[j] = 0;
		}
	}
}

ll min_factor(ll x) {
	for (int i = 0; i < p.size(); i++) {
		if (x % p[i] == 0) {
			return p[i];
		}
	}
	return 1; // ありえない
}


void solve() {
	rep(i, 100005) prime[i] = true;
	sieve_of_eratosthenes(prime, 100005);
	rep(i, 100001) {
		if (prime[i] == 0) continue;
		p.push_back(i);
	}

	for (ll i = 0; i < p.size(); i++) {
		ll x = p[i];
		ll s = L / x + (L % x != 0);
		ll t = H / x;
		ll tmp = -1;
		for (ll j = s; j <= t; j++) {
			ll z = min_factor(j);
			if (z < x) continue;
			tmp = max(tmp, x * j);
		}
		if (tmp != -1) ans = tmp;
	}
	cout << ans << endl;
}

int main() {
	cin >> L >> H;
	solve();
	return 0;
}


0