結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
13,752 KB
testcase_01 AC 3 ms
6,816 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 3 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 3 ms
6,944 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 3 ms
6,944 KB
testcase_26 TLE -
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 ;
}
int min_prime_factor(ll x){

  for (const int &val : primes){
    if (val * val > x)break;
    if (x % val == 0){
      return val;
    }
  }
  return x;
}
ll L,H;

ll result;
int main(){

  cin >> L >>H;
  gen_prime();
  result = 0;
  sort(primes.begin(), primes.end());

  for (ll i = primes.size() - 1; i >=0; i--){
    for (ll k = H / primes[i]; k >= primes[i]; k--){
      if ((ll)primes[i] * k >= L){
	ll tmp = min_prime_factor((ll)primes[i] * k);
	if (tmp >= primes[i]){
	  cout << (ll)primes[i] * k << endl;
	  return 0;
	}
      }
    }
  }


}
0