結果

問題 No.1058 素敵な数
ユーザー ShibuyapShibuyap
提出日時 2020-05-22 21:38:09
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 1,394 bytes
コンパイル時間 2,243 ms
コンパイル使用メモリ 200,524 KB
実行使用メモリ 8,632 KB
最終ジャッジ日時 2024-04-15 16:15:45
合計ジャッジ時間 2,863 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}


/*
    Max_Prime以下の素数をprimes[]に格納
*/

const int Max_Prime = 1000000;
int tmp_primes[Max_Prime];
vector<int> primes;

void PrimeInit() {
    rep(i,Max_Prime)tmp_primes[i] = 1;
    tmp_primes[0] = 0;
    tmp_primes[1] = 0;

    rep(i,Max_Prime){
        if(tmp_primes[i] == 0)continue;
        int j = 2;
        while(i * j <= Max_Prime){
            tmp_primes[i*j] = 0;
            j++;
        }
    }
    
    rep(i,Max_Prime){
        if(tmp_primes[i])primes.push_back(i);
    }
}

int main(){
    PrimeInit();

    vector<ll> v;
    rep(i,primes.size()){
        if(primes[i] > 100000){
            v.push_back(primes[i]);
        }
    }

    rep(i,10){
       // cout << v[i] << endl;
    }

    ll ans[100];
    rep(i,100)ans[i] = 1001001001001001001;
    rep(i,10){
        srep(j,i,10){
            ans[i*10+j] = v[i] * v[j];
        }
    }

    sort(ans,ans+100);

    int n;
    cin >> n;

    if(n == 1){
        cout << 1 << endl;
    }else{
        n--;
        n--;
        cout << ans[n] << endl;
    }

    return 0;
}
 
 
0