結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー togatogatogatoga
提出日時 2016-05-14 00:04:32
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,519 bytes
コンパイル時間 1,322 ms
コンパイル使用メモリ 169,400 KB
実行使用メモリ 13,760 KB
最終ジャッジ日時 2024-04-15 17:34:18
合計ジャッジ時間 4,499 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
13,760 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 4 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 3 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 3 ms
6,940 KB
testcase_12 AC 3 ms
6,944 KB
testcase_13 AC 23 ms
6,940 KB
testcase_14 AC 23 ms
6,940 KB
testcase_15 AC 22 ms
6,940 KB
testcase_16 AC 213 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 3 ms
6,944 KB
testcase_20 AC 53 ms
6,940 KB
testcase_21 AC 53 ms
6,940 KB
testcase_22 AC 41 ms
6,940 KB
testcase_23 AC 79 ms
6,944 KB
testcase_24 TLE -
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 <bits/stdc++.h>

#define mp       make_pair
#define mt	 make_tuple
#define pb       push_back
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    pair<int,int>      pii;
typedef    pair<long,long>    pll;

const int INF=1<<29;
const double EPS=1e-9;
const int MOD = 100000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int MAX_N = 100002;
bool is_prime[MAX_N];
vector<int> primes;
void gen_prime(){
  memset(is_prime, true, sizeof(is_prime));
  is_prime[0] = false;
  is_prime[1] = false;
  for (int i = 2; i < MAX_N; i++){
    if (not is_prime[i])continue;
    primes.push_back(i);
    for (int j = i + i; j < MAX_N; j += i){
      is_prime[j] = false;
    }
  }
  return ;
}
ll L,H;
set<ll> flag;

ll max_value;
void get_max_value(ll val, int index){

  if (val > H)return ;
  if (flag.size() > 0 and L <= val and val <= H){
    //    cout << val << endl;
    max_value = max(max_value, val);
  }
  flag.insert(val);
  for (int i = index; i < primes.size(); i++){
    if (val * primes[i] <= H){
      if (flag.count(val * primes[i]) > 0)continue;
      get_max_value(val * primes[i], index);
    }
  }
}

ll result;
int main(){
  cin >> L >>H;
  gen_prime();
  result = 0;
  sort(primes.begin(), primes.end());
  for (int i = primes.size() - 1; i >=0; i--){
    flag.clear();
    max_value = 0;
    get_max_value(primes[i], i);
    if (max_value != 0){
      break;
    }

  }

  cout << max_value << endl;
}
0