結果
| 問題 |
No.371 ぼく悪いプライムじゃないよ
|
| コンテスト | |
| ユーザー |
btk
|
| 提出日時 | 2016-05-14 00:24:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,077 bytes |
| コンパイル時間 | 1,397 ms |
| コンパイル使用メモリ | 173,316 KB |
| 実行使用メモリ | 13,636 KB |
| 最終ジャッジ日時 | 2024-10-05 19:24:28 |
| 合計ジャッジ時間 | 4,576 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 TLE * 1 -- * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
struct INIT{INIT(){ios::sync_with_stdio(false);cin.tie(0);}}init;
typedef long long LL;
vector<LL> prime;
struct eratosthenes{
eratosthenes(){
vector<bool> used(110001,true);
for(int i = 2; i*i <= 110000; i++){
if(used[i]){
for(int j = i+i; j <= 110000; j+=i)used[j]=false;
}
}
for(int i = 2; i <= 110000; i++)
if(used[i])prime.push_back(i);
}
}e;
int main() {
LL L,H;
cin >> L >> H;
LL b=0;
for(; prime[b]*prime[b] <= H; b++);
b--;
L=max(L,prime[b]*prime[b]);
pair<int,LL> res(0,0);
for(LL i = L; i <= H; i++){
LL v=i;
LL d=114514;
[&](){
for(int j = 0;prime[j]*prime[j]<=v; j++){
while(v%prime[j]==0){
d=min(d,prime[j]);
if(d<res.first)return;
v/=prime[j];
}
}
if(v==i)return;
res=max(res,make_pair((int)d,i));
}();
}
cout << res.second<<endl;
return 0;
}
btk