結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー rickythetarickytheta
提出日時 2016-05-13 22:50:21
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,369 bytes
コンパイル時間 1,496 ms
コンパイル使用メモリ 161,476 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-04-15 16:43:19
合計ジャッジ時間 4,699 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 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 3 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 3 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 3 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 AC 10 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 602 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 TLE -
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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
      |   ~~~~~^~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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];
vi 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 = H/x;
    while(ub*x>=L && ub>1){
      ll mfct=830252521;
      if(ub<125252 && isp[ub]){
        mfct = ub;
      }else{
        REP(j,ps.size()){
          if(ub%ps[j]==0){
            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;
}
0