結果
問題 |
No.371 ぼく悪いプライムじゃないよ
|
ユーザー |
![]() |
提出日時 | 2016-10-08 23:16:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 589 bytes |
コンパイル時間 | 510 ms |
コンパイル使用メモリ | 69,372 KB |
実行使用メモリ | 13,640 KB |
最終ジャッジ日時 | 2024-11-21 20:39:03 |
合計ジャッジ時間 | 38,224 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 WA * 2 TLE * 18 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> using namespace std; long long min_prime_check(long long x) { if (x % 2 == 0) return 2; for (long long i = 3; i*i <= x; i += 2) { if (x % i == 0)return i; } return x; } int main() { cin.tie(0); ios::sync_with_stdio(false); long long L, H; cin >> L >> H; long long P = 2, Ans = 0; if (L % 2 == 0) { Ans = L; } else { Ans = L + 1; } for (long long i = L + 1 - L % 2; i <= H; i += 2) { long long temp = min_prime_check(i); if (temp != i && temp >= P) { P = temp; Ans = i; } } cout << Ans << endl; }