結果

問題 No.1058 素敵な数
ユーザー snow39snow39
提出日時 2020-05-22 22:17:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 997 bytes
コンパイル時間 1,080 ms
コンパイル使用メモリ 101,672 KB
実行使用メモリ 9,764 KB
最終ジャッジ日時 2024-04-15 17:12:42
合計ジャッジ時間 2,026 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 31 ms
8,224 KB
testcase_02 AC 31 ms
8,484 KB
testcase_03 AC 32 ms
8,356 KB
testcase_04 AC 31 ms
8,484 KB
testcase_05 AC 32 ms
8,740 KB
testcase_06 AC 32 ms
9,764 KB
testcase_07 AC 33 ms
8,868 KB
testcase_08 AC 31 ms
8,356 KB
testcase_09 AC 32 ms
8,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

const int L=110000;
const int D=1e5;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin>>N;

  if(N==1){
    cout<<1<<endl;
    return 0;
  }

  vector<int> isprime(L+1,1);
  vector<ll> primes;
  for(ll i=2;i<=L;i++){
    if(isprime[i]==0) continue;
    if(i>D) primes.push_back(i);
    for(ll j=2;i*j<=L;j++) isprime[i*j]=0;
  }
  N--;

  vector<ll> v;
  for(int i=0;i<primes.size();i++) for(int j=i;j<primes.size();j++) v.push_back(primes[i]*primes[j]);
  sort(v.begin(),v.end());
  cout<<v[N-1]<<endl;



  return 0;
}
0