結果

問題 No.1058 素敵な数
ユーザー わなわなわなわな
提出日時 2020-05-22 21:31:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 678 bytes
コンパイル時間 615 ms
コンパイル使用メモリ 63,600 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 15:58:22
合計ジャッジ時間 2,540 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;
bool is_prime(int n){//素数判定
    for(int i = 0; i * i < n; i++){
        if(n % i == 0) return false;
    }
    return n != 1;
}
int main(){
    long long N;
    cin >> N;
    if(N == 1){
        cout << 1 << endl;
        return 0;
    }
    N -= 1;
    long long M = 1e5 + 1;
    while(1){
        if(is_prime(M)){
            M += 2;
            continue;
        }
        for(int i = 2; i < 1e5 + 1; i++){
            if(M % i == 0) {
                M += 2;
                continue;
            }
        }
        N--;
        if(N == 0){
            cout << M << endl;
            break;
        }
        M += 2;
    }
}
0