結果

問題 No.1058 素敵な数
ユーザー monnumonnu
提出日時 2020-05-26 22:07:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 852 bytes
コンパイル時間 2,636 ms
コンパイル使用メモリ 173,184 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 04:37:22
合計ジャッジ時間 2,977 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
#define INF 1000000000000000000
#define MOD 1000000007

#define MAX 200000
vector<int> p;
vector<bool> p_table(MAX+1,true);
void prime(){
  p_table.at(0)=false,p_table.at(1)=false;
  for(int i=2;i<=MAX;i++){
    if(p_table.at(i)){
      p.push_back(i);
      for(int j=2;i*j<=MAX;j++){
        p_table.at(i*j)=false;
      }
    }
  }
}


int main(){
  int N;
  cin>>N;
  vector<int> b;
  vector<ll> a;
  prime();
  int n=p.size();
  a.push_back(1);
  for(int i=0;i<n;i++){
    if(p.at(i)>100000){
      b.push_back(p.at(i));
      if(b.size()==10){
        break;
      }
    }
  }

  for(int i=0;i<9;i++){
    for(int j=i;j<9;j++){
      a.push_back((ll)b.at(i)*(ll)b.at(j));
    }
  }
  sort(a.begin(),a.end());

  cout<<a.at(N-1)<<endl;
}
0