結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー itezpaceitezpace
提出日時 2016-10-08 09:08:02
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 821 bytes
コンパイル時間 676 ms
コンパイル使用メモリ 61,928 KB
実行使用メモリ 14,704 KB
最終ジャッジ日時 2024-05-01 15:27:35
合計ジャッジ時間 4,742 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 RE -
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 RE -
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 456 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 RE -
testcase_18 AC 2 ms
5,376 KB
testcase_19 RE -
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
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 <iostream>
#include <vector>
using namespace std;
typedef long long ll;
vector<int> calc(ll N){
  vector<int> v(N,1);
  v[0]=0;
  v[1]=0;
  for(ll i=2;i*i<=N;++i){
    if(v[i]){
      for(ll j=i*i;j<=N;j+=i){
        if(v[j]) v[j]=0;
      }
    }
  }
  vector<int> v2;
  for(int i=0;i<N;++i){
    if(v[i]) v2.push_back(i);
  }
  return v2;
}
int main(){
  ll L=0,H=0;cin>>L>>H;
  vector<int> v=calc(H+1);
  ll ans=0;
  int lf=0;
  for(int i=v.size()-1;i>=0;--i){
    if(lf==0){
    for(ll j=H;j>=L;--j){
      if(j%v[i]==0 && j/v[i]!=1){
        int f=0;
        for(int k=i-1;k>=0;--k){
          if(j%v[k]==0){
            f=1;
            break;
          }
        } // k
        if(f==0){
          ans=j;
          lf=1;
          break;
        }
      }
    } //j
    } //lf
  } //i
  cout<<ans<<endl;
}
0