結果

問題 No.1058 素敵な数
ユーザー StrorkisStrorkis
提出日時 2020-05-22 21:45:35
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 697 bytes
コンパイル時間 833 ms
コンパイル使用メモリ 78,496 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 16:28:04
合計ジャッジ時間 1,334 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    int N;
    std::cin >> N;

    const int K = 200000;

    std::vector<long long> u;
    std::vector<bool> v(K);
    for (int i = 2; i < K; i++) {
        if (v[i] == true) continue;
        if (i > 100000) {
            u.push_back(i);
            if (u.size() > 10) break;
            continue;
        }
        for (int j = i; j < K; j += i) {
            v[j] = true;
        }
    }

    std::vector<long long> w = {1};
    for (int i = 0; i < 11; i++) {
        for (int j = i; j < 11; j++) {
            w.push_back(u[i] * u[j]);
        }
    }
    sort(w.begin(), w.end());

    std::cout << w[N - 1] << "\n";
}
0