結果

問題 No.1058 素敵な数
ユーザー minatominato
提出日時 2020-05-22 21:38:50
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 1,764 bytes
コンパイル時間 3,353 ms
コンパイル使用メモリ 238,572 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 16:17:46
合計ジャッジ時間 4,044 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
void print() { cout << "\n"; }
template <class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////

vector<bool> sieve(int N) {
    vector<bool> ret(N+1,true);
    
    ret[0] = ret[1] = false;
    for (int i = 2; i*i <= N; ++i) {
        if (ret[i]) {
            for (int j = 2; j*i <= N; ++j) {
                ret[j*i] = false;
            }
        }
    }

    return ret;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    auto prime = sieve(1000000);
    vector<ll> arr;
    for (int i = 100001;;i++) {
        if (prime[i]) arr.emplace_back(i);
        if (arr.size()>=10) break;
    }
    vector<ll> ans;
    ans.emplace_back(1);
    rep(i,10) {
        rep(j,10) {
            ans.emplace_back(arr[i]*arr[j]);
        }
    }
    sort(all(ans));
    ans.erase(unique(begin(ans), end(ans)), end(ans));
    int N; cin >> N;
    cout << ans[--N] << ln;
}
0