結果

問題 No.1058 素敵な数
ユーザー RubikunRubikun
提出日時 2020-05-22 21:26:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 1,309 bytes
コンパイル時間 1,824 ms
コンパイル使用メモリ 173,044 KB
実行使用メモリ 13,460 KB
最終ジャッジ日時 2024-04-15 15:44:55
合計ジャッジ時間 3,008 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
12,416 KB
testcase_01 AC 59 ms
12,856 KB
testcase_02 AC 60 ms
13,156 KB
testcase_03 AC 60 ms
12,648 KB
testcase_04 AC 60 ms
13,140 KB
testcase_05 AC 60 ms
12,052 KB
testcase_06 AC 61 ms
13,460 KB
testcase_07 AC 59 ms
12,848 KB
testcase_08 AC 59 ms
12,992 KB
testcase_09 AC 60 ms
12,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

vector<int> prime;//i番目の素数
bool is_prime[MAX+1];

void sieve(int n){
    for(int i=0;i<=n;i++){
        is_prime[i]=true;
    }
    
    is_prime[0]=is_prime[1]=false;
    
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime.push_back(i);
            for(int j=2*i;j<=n;j+=i){
                is_prime[j] = false;
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    sieve(MAX-3);
    vector<ll> X,ans;
    for(int i=100001;i<=110000;i++){
        if(is_prime[i]) X.push_back(i);
    }
    
    for(ll a:X){
        for(ll b:X){
            ans.push_back(a*b);
        }
    }
    sort(all(ans));
    ans.erase(unique(all(ans)),ans.end());
    
    int N;cin>>N;
    N-=2;
    if(N<0) cout<<1<<endl;
    else cout<<ans[N]<<endl;
}


0