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