結果

問題 No.1058 素敵な数
ユーザー root__786root__786
提出日時 2020-05-22 21:56:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 558 bytes
コンパイル時間 2,449 ms
コンパイル使用メモリ 200,032 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 16:43:11
合計ジャッジ時間 2,765 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
vector<ll> a;
bool pp(ll n){
    if(n<=1) return false;
    else if(n==2 || n==3) return true;
    else if(n%2==0 || n%3==0) return false;
    else{
        for(ll i=5;i*i<=n;i+=6){
            if(n%i==0 || n%(i+2)==0) return false;
            
        }
        return true;
    }
}
int main() {
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        if(!pp(i)) a.push_back(i);
    }
    sort(a.begin(),a.end());
    cout<<a[0]<<endl;
    return 0;
}
0