結果
| 問題 |
No.371 ぼく悪いプライムじゃないよ
|
| コンテスト | |
| ユーザー |
🐬hec
|
| 提出日時 | 2016-05-14 01:45:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,538 bytes |
| コンパイル時間 | 1,447 ms |
| コンパイル使用メモリ | 166,368 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2024-10-05 21:26:18 |
| 合計ジャッジ時間 | 5,561 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 TLE * 2 -- * 21 |
ソースコード
#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;
}
🐬hec