結果

問題 No.1058 素敵な数
ユーザー wkwk
提出日時 2020-05-22 21:31:43
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 719 bytes
コンパイル時間 2,024 ms
コンパイル使用メモリ 169,116 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 15:59:18
合計ジャッジ時間 2,537 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
using namespace std;

int main()
{   
    int N; cin >> N;
    long p[12];
    int ind = 0;
    long prime = 100001;
    while(ind < 10){
        bool ok = true;
        for(long i=2; i*i<=prime; i++)
            if(prime % i == 0){
                ok = false;
                break;
            }
        if(ok){
            p[ind] = prime;
            ind++;
        }
        prime++;
    }
    //REP(i, 10) cout << p[i] << endl;
    vector<long> seki;
    REP(i, 10) for(int j=i; j<10; j++) seki.push_back(p[i]*p[j]);
    sort(seki.begin(), seki.end());
    if(N==1) cout << 1 << endl;
    else cout << seki[N-2] << endl;
    return 0;
}

0