結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー Mr.SpockMr.Spock
提出日時 2021-12-05 15:29:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,538 bytes
コンパイル時間 1,697 ms
コンパイル使用メモリ 166,992 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-09-21 14:02:31
合計ジャッジ時間 4,822 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,048 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 TLE -
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>
using namespace std;
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "[";
	for (int i = 0; i < int(v.size()); ++i) {
		os << v[i];
		if (i != v.size() - 1) {
			os << ", ";
		}
	}
	os << "]\n";
	return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "[";
	os << p.first;
	os << ", ";
	os << p.second;
	os << "]";
	return os;
}
#ifndef ONLINE_JUDGE
#define debug(x) cout << (#x) << " is " << (x) << endl
#else
#define debug(...) 42
#endif
const int maxN = 1e5 + 7;
vector<int>p(maxN + 7, true);
vector<int>tt;
void go() {
	p[1] = false;
	p[0] = false;
	for (int i = 2; i <= maxN; i++) {
		if (p[i]) {
			tt.push_back(i);
			for (int j = 2 * i; j <= maxN; j += i) {
				p[j] = false;
			}
		}
	}
}
int ok(int n) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			return i;
		}
	}
	return n;
}
void solve() {
	long long l, r;
	cin >> l >> r;
	long long ans = 0;
	for (int i = int(tt.size() - 1); i >= 0; i--) {
		if (1ll * tt[i]*tt[i] <= r) {
			long long nx = tt[i];
			long long L = max(1ll * nx * nx, l);
			long long R = r / nx * nx;
			for (long long j = R; j >= L; j -= nx) {
				long long g = ok(j);
				if (g == nx) {
					cout << j << endl;
					return ;
				}
			}
		}
	}
}
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int T;
	//cin >> T;
	T = 1;
	while (T--) {
		go();
		solve();
	}
}
0