結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー ei1333333
提出日時 2016-05-13 23:39:10
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 500 bytes
コンパイル時間 1,069 ms
コンパイル使用メモリ 159,216 KB
実行使用メモリ 13,640 KB
最終ジャッジ日時 2024-10-05 18:21:05
合計ジャッジ時間 4,145 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 12 WA * 27 TLE * 1 -- * 2
権限があれば一括ダウンロードができます

ソースコード

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