結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー treeonetreeone
提出日時 2016-07-08 11:31:00
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,221 bytes
コンパイル時間 1,426 ms
コンパイル使用メモリ 161,136 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 01:05:15
合計ジャッジ時間 2,975 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 4 ms
5,376 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 AC 4 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 4 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 3 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 4 ms
5,376 KB
testcase_18 AC 4 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
testcase_20 WA -
testcase_21 AC 4 ms
5,376 KB
testcase_22 WA -
testcase_23 AC 4 ms
5,376 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 4 ms
5,376 KB
testcase_28 AC 3 ms
5,376 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 WA -
testcase_44 AC 3 ms
5,376 KB
testcase_45 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

vector<int> prime;
bool isprime[100010];

void sieve(int n){
    rep(i, 0, n + 1) isprime[i] = true;
    isprime[0] = isprime[1] = false;
    rep(i, 2, n + 1){
        if(isprime[i]) prime. push_back(i);
        for(int j = 2*i; j <= n; j += i) isprime[j] = false;
    }
    return;
}

signed main(){
    int l, h, a, ans = -1;
    cin >> l >> h;
    sieve(100000);
    a = prime.back();
    if(h - l >= 100000){
        rep(i, 0, 200000){
            if(i*a > h){
                ans = a*(i - 1);
                break;
            }
        }
    }else{
        vector<int> cand;
        bool f[100010];
        memset(f, true, sizeof(f));
        rep(i, 0, prime.size()){
            int st = (l - 1) / prime[i] + 1;
            for(int j = st*prime[i]; j <= h; j += prime[i]){
                if(j != prime[i] && f[j - l] == true) cand. push_back(j);
                f[j - l] = false;                
            }
        }
        ans = cand.back();
    }
    cout << ans << endl;
}
0