結果
問題 |
No.371 ぼく悪いプライムじゃないよ
|
ユーザー |
![]() |
提出日時 | 2016-05-13 22:55:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,385 bytes |
コンパイル時間 | 1,450 ms |
コンパイル使用メモリ | 160,492 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2024-10-05 17:19:17 |
合計ジャッジ時間 | 4,674 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 18 WA * 3 TLE * 1 -- * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:27:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | scanf("%lld%lld",&L,&H); | ~~~~~^~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef complex<double> P; typedef pair<int,int> pii; #define REP(i,n) for(ll i=0;i<n;++i) #define REPR(i,n) for(ll i=1;i<n;++i) #define FOR(i,a,b) for(ll i=a;i<b;++i) #define DEBUG(x) cout<<#x<<": "<<x<<endl #define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl #define ALL(a) (a).begin(),(a).end() #define MOD (ll)(1e9+7) #define ADD(a,b) a=((a)+(b))%MOD #define FIX(a) ((a)%MOD+MOD)%MOD ll L,H; bool isp[125252]; vl ps; int main(){ scanf("%lld%lld",&L,&H); REP(i,125252)isp[i]=true; isp[0]=isp[1]=false; FOR(x,2,125252){ if(!isp[x])continue; ps.push_back(x); { int it = x+x; while(it<125252){ isp[it]=false; it+=x; } } } ll ans = 1; ll mxmn = 1; REP(i,ps.size()){ ll x = ps[ps.size()-1-i]; if(x<mxmn)break; ll ub = min(H/x,x); while(ub*x>=L && ub>1){ ll mfct=x; if(ub<125252 && isp[ub]){ mfct = min(x,ub); }else{ REP(j,ps.size()){ if(ub%ps[j]==0){ mfct=min(mfct,ps[j]); break; } } } ll fct = min(mfct,x); if(fct>mxmn || (fct==mxmn&&ub*x>ans)){ ans = ub*x; mxmn = fct; } --ub; } } printf("%lld\n",ans); return 0; }