結果

問題 No.1058 素敵な数
ユーザー onsen_manjuuuonsen_manjuuu
提出日時 2020-06-16 15:18:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 848 bytes
コンパイル時間 1,621 ms
コンパイル使用メモリ 171,628 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 18:08:00
合計ジャッジ時間 2,276 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long;

vector<ll> divisor(ll n){
    vector<ll> res;
    for(ll i = 1LL; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            ll j = n / i;
            if(i != j)res.push_back(j);
        }
    }
    sort(res.begin(),res.end());
    return res;
}

int main()
{
    vector<ll> prime;
    for(int i = 100001; prime.size() <= 100; i++) {
        if(divisor(i).size() == 2)prime.push_back(i);
    }
    vector<ll> a;
    int m = prime.size();
    for(int i = 0; i < m; i++) {
        for(int j = 0; j < m; j++) {
            a.emplace_back(prime[i] * prime[j]);
        }
    }
    sort(a.begin(), a.end());
    unique(a.begin(), a.end());
    int n; cin >> n;
    if(n == 1) {
        cout << 1 << endl;
    } else {
        cout << a[n - 2] << endl;
    }
}
0