結果

問題 No.312 置換処理
ユーザー ugis_progugis_prog
提出日時 2018-12-08 09:54:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,166 bytes
コンパイル時間 2,184 ms
コンパイル使用メモリ 148,776 KB
実行使用メモリ 15,560 KB
最終ジャッジ日時 2023-10-12 04:54:29
合計ジャッジ時間 10,461 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 137 ms
15,300 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 138 ms
15,364 KB
testcase_23 WA -
testcase_24 AC 138 ms
15,528 KB
testcase_25 AC 138 ms
15,384 KB
testcase_26 AC 138 ms
15,364 KB
testcase_27 WA -
testcase_28 AC 141 ms
15,296 KB
testcase_29 AC 139 ms
15,472 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 136 ms
15,364 KB
testcase_37 AC 136 ms
15,304 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 136 ms
15,532 KB
testcase_42 AC 138 ms
15,316 KB
testcase_43 AC 138 ms
15,416 KB
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)

std::vector<bool> is_prime(100001000,true);
std::vector<int> prime;

void SieveofEratosthenes(){
    prime.reserve(1000000);
    is_prime[0] = is_prime[1] = false;
    for(int i=2;i<=100000000;i+=2) is_prime[i] = false;
    for(int i=3;i<=100000000;i+=3) is_prime[i] = false;
    is_prime[2] = is_prime[3] = true;
    prime.push_back(2); prime.push_back(3);

    for(int i=5;i<=10000;++i){
        if(!is_prime[i]) continue;
        for(int j = i*2; j<=100000000;j*=2){
            is_prime[j] = false;
        }
        prime.push_back(i);
    }
}

int main(){
    SieveofEratosthenes();
    int N;
    cin >> N;
    for(int i=0;i<prime.size();++i){
        if(N % prime[i] == 0 && prime[i] != 2){
            cout << prime[i] << endl;
            return 0;
        }
    }
}
0