結果

問題 No.1058 素敵な数
ユーザー uw_yu1rabbituw_yu1rabbit
提出日時 2020-08-19 12:52:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 918 bytes
コンパイル時間 997 ms
コンパイル使用メモリ 88,416 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 03:22:04
合計ジャッジ時間 1,491 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
#define rep(i, n) for (i32 i = 0; i < (i32)(n); i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using P = pair<i64,i64>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i32 n;
cin >> n;
vector<i64> a(1,1);
i32 i = 1e5 + 1;
while(a.size() < 10){
    bool flag =true;
    for(i32 g = 2; g * g <= i; g++){
        if(i % g == 0){
            flag = false;
            break;
        }
    }
    if(flag) a.emplace_back(i);
    i++;
}
vector<i64> ans(1,1);
for(i32 i = 1; i < 10; i++){
    for(i32 j = 1; j < 10; j++){
        ans.emplace_back(a[i] * a[j]);
    }
}

sort(all(ans));
ans.erase(unique(all(ans)),ans.end());

cout << ans[n - 1] << endl;
}
0