結果

問題 No.1058 素敵な数
ユーザー pockynypockyny
提出日時 2020-05-22 22:19:42
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 698 bytes
コンパイル時間 1,085 ms
コンパイル使用メモリ 86,216 KB
最終ジャッジ日時 2025-01-10 14:51:11
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

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