結果

問題 No.312 置換処理
ユーザー RyuRyu
提出日時 2017-12-29 16:38:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 780 bytes
コンパイル時間 542 ms
コンパイル使用メモリ 73,684 KB
実行使用メモリ 4,728 KB
最終ジャッジ日時 2023-08-23 09:00:50
合計ジャッジ時間 4,703 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 12 ms
4,404 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 WA -
testcase_11 AC 12 ms
4,396 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 WA -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 WA -
testcase_19 WA -
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 4 ms
4,376 KB
testcase_32 WA -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 AC 2 ms
4,380 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 RE -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cmath>

using namespace std;

bool isprime[1000000];

void search(int n)
{
    memset(isprime, true, sizeof(isprime));

    isprime[0] = false;
    isprime[1] = false;

    for(int i = 2; i < sqrt(n); i++)
    {
        if(isprime[i])
        {
            for(int j = 0; i * (j + 2) < n; j++)
            {
                isprime[i * (j + 2)] = false;
            }
        }
    }
}

using ll = long long int;

int main()
{
    ll N; 
    cin >> N;
    search(N);
    ll num = 0ll;
    for(int i = 0; i < sqrt(N); i++)
    {
       if(isprime[i])
       {
           if(N % i == 0)
           {
               num = i;
           }
       }
    }

    cout << num << endl;

    return 0;
}
0