結果

問題 No.1058 素敵な数
ユーザー auauaauaua
提出日時 2020-05-22 21:37:57
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 1,064 bytes
コンパイル時間 2,042 ms
コンパイル使用メモリ 173,452 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 16:15:38
合計ジャッジ時間 2,317 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
//エラトステネスの篩
vector<bool> IsPrime(1000010,true);
void sieve(ll n){
    IsPrime[0]=0;
    IsPrime[1]=0;
    REP(i,2,n+1){
        if(IsPrime[i]){
            ll k=2;
            while(k*i<=n){
                IsPrime[k*i]=0;
                k++;
            }
        }
    }
}
signed main(){
    ll cnt=0;
    ll n;cin>>n;
    sieve(1000000);
    vector<ll>d(0);
    rep(i,1000000){
        if(d.size()==10)break;
        if(IsPrime[i]&&i>100000)d.pb(i);
    }
    vector<ll>ans(0);
    rep(i,d.size()){
        REP(j,i,d.size())ans.pb(d[i]*d[j]);
    }
    ans.pb(1);
    sort(all(ans));
    cout<<ans[n-1]<<endl;
}
0