結果

問題 No.1058 素敵な数
ユーザー pockynypockyny
提出日時 2020-05-22 22:19:42
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 698 bytes
コンパイル時間 1,121 ms
コンパイル使用メモリ 90,740 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 17:14:59
合計ジャッジ時間 1,611 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
long long num[102000] = {};
vector<long long> v;
set<long long> s;
int main(){
    long long i,j,n; cin >> n;
    for(i=2;i<=101000;i++){
        if(num[i]!=0) continue;
        for(j=i;j<=101000;j+=i){
            if(num[j]==0) num[j] = i;
        }
    }
    for(i=100001;i<=101000;i++){
        if(num[i]!=i) continue;
        for(j=100001;j<=101000;j++){
            if(num[j]!=j) continue;
            if(s.count(i*j)==0){
                v.push_back(i*j);
                s.insert(i*j);
            }
        }
    }
    v.push_back(1);
    sort(v.begin(),v.end());
    cout << v[n - 1] << endl;
}
0