結果

問題 No.1058 素敵な数
ユーザー pekempeypekempey
提出日時 2020-05-22 21:25:35
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 2,699 ms
コンパイル使用メモリ 202,260 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 15:41:57
合計ジャッジ時間 3,093 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

bool is_prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

int main() {
    vector<ll> P;
    for (ll i = 100001; P.size() <= 10; i++) {
        if (is_prime(i)) {
            P.push_back(i);
        }
    }
    vector<ll> Q;
    Q.push_back(1);
    rep(i, P.size()) rep(j, i + 1) Q.push_back(P[i] * P[j]);
    sort(range(Q));
    int n; cin >> n;
    cout << Q[n - 1] << endl;
}
0