結果
| 問題 |
No.371 ぼく悪いプライムじゃないよ
|
| コンテスト | |
| ユーザー |
kyuridenamida
|
| 提出日時 | 2016-05-18 23:03:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 46 ms / 1,000 ms |
| コード長 | 732 bytes |
| コンパイル時間 | 1,596 ms |
| コンパイル使用メモリ | 159,336 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-30 18:21:17 |
| 合計ジャッジ時間 | 3,021 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 42 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
long long g(long long n){
long long mx = 1e18;
for(long long i = 2 ; i*i <= n ; i++){
if( n % i == 0 ) return i;
}
return n;
}
long long prime(long long n){
long long mx = 1e18;
for(long long i = 2 ; i*i <= n ; i++){
if( n % i == 0 ) return 0;
}
return 1;
}
int main(){
long long L,H;
cin >> L >> H;
for(long long i = sqrt(H)+0.5 ; i >= 1 ; i--){
if( prime(i) ){
long long x = (H/i);
while( x >= i and g(x) < i and x*i >= L ) x--;
if( x != 1 and g(x) >= i and x*i >= L and x*i <= H) {
cout << x*i << endl;
return 0;
}
}
}
}
kyuridenamida