結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー 🐬hec🐬hec
提出日時 2016-05-14 01:45:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,538 bytes
コンパイル時間 1,471 ms
コンパイル使用メモリ 162,928 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2024-04-15 19:04:45
合計ジャッジ時間 5,659 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 4 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 TLE -
testcase_23 AC 4 ms
5,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>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;

using ll=long long;


const int limit=100000;
bool prime[limit+1];

void init(){
	rep(i,limit+1) prime[i]=true;
	prime[0]=prime[1]=false;
	for(ll i=2;i*i<=limit;++i){
		if(prime[i])
			for(ll j=i*i;j<=limit;j+=i)
				prime[j]=false;
	}
	return;
}



int main(void){
	init();
	ll l,h;
	cin >> l >> h;
	
	for(ll p=2LL;p*p<=h;++p){
		if(prime[p]==false) continue;
		if(p*p>=l) l=p*p;
	}

	ll ans=0LL,fmax=0LL;
	for(ll i=l;i<=h;++i){
		ll cur=i,res=1LL;
		for(ll f=2LL;f*f<=cur;++f){
			if(prime[f]==false) continue;
			if(cur%f==0){
				cur/=f;
				res=f;
				break;
			}
		}

		if(cur==i) continue;
		if(fmax < res || (fmax == res  && ans < i)) fmax=res,ans=i;		
	}
	cout << ans << endl;
	return 0;
}
0