結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー ei1333333ei1333333
提出日時 2016-05-13 23:39:10
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 500 bytes
コンパイル時間 1,334 ms
コンパイル使用メモリ 159,852 KB
実行使用メモリ 13,880 KB
最終ジャッジ日時 2024-04-15 17:19:05
合計ジャッジ時間 4,581 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,012 KB
testcase_01 WA -
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 WA -
testcase_10 AC 2 ms
6,940 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
6,940 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 3 ms
6,940 KB
testcase_28 AC 53 ms
6,944 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 TLE -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

typedef long long int64;
int64 prime_factor(int64 n)
{
  for(int64 i = 2; i * i <= n; i++) if(n % i == 0) return(i);
  return(-1);
}
int main()
{
  
  int64 L, H;
  cin >> L >> H;
  for(int64 i = 100000; i >= 2; i--) {
    if(L <= i * i && i * i <= H) {
      cout << i * i << endl;
      exit(0);
    }
  }
  pair< int64, int64 > ret(2, 2);
  for(int64 i = L; i <= H; i++) {
    ret = max(ret, {prime_factor(i), i});
  }
  cout << ret.second << endl;
}
0