結果

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

テストケース

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

ソースコード

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;
}

/***********debug tools***********/
template<class T> ostream& operator<<(ostream& os, const pair<T,T>& p){os << "{" << p.first << "," << p.second << "}";return os; }
template<class T> inline void print(pair<T,T> p){cerr << p << endl;}
template<class T> inline void print(vector<T> arr) {cerr << "["; for(int i = 0; i < (int)arr.size(); i++)cerr << arr[i] << (i == (int)arr.size() - 1 ? "]" : ",");cerr << endl;}
template<class T> inline void print(vector<vector<T>> arr) {cerr << "[-------------------" << endl; for(int i = 0; i < (int)arr.size(); i++) { print(arr[i]);} cerr << "-------------------]" << endl;}
/*********************************/


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());
    int n; cin >> n;
    if(n == 1) {
        cout << 1 << endl;
    } else {
        cout << a[n - 2] << endl;
    }
}
0