結果

問題 No.1058 素敵な数
ユーザー beetbeet
提出日時 2020-05-22 21:39:10
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,105 bytes
コンパイル時間 2,636 ms
コンパイル使用メモリ 211,368 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 16:18:17
合計ジャッジ時間 3,301 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename V>
V compress(V vs){
  sort(vs.begin(),vs.end());
  vs.erase(unique(vs.begin(),vs.end()),vs.end());
  return vs;
}
template<typename T>
map<T, Int> dict(const vector<T> &vs){
  map<T, Int> res;
  for(Int i=0;i<(Int)vs.size();i++)
    res[vs[i]]=i;
  return res;
}
map<char, Int> dict(const string &s){
  return dict(vector<char>(s.begin(),s.end()));
}

//INSERT ABOVE HERE
const Int MAX = 1e5+1000;
Int fs[MAX]={};

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

  vector<Int> ans;
  for(Int i=2;i<MAX;i++){
    if(fs[i]) continue;
    if(i>=1e5) ans.emplace_back(i);
    for(Int j=i;j<MAX;j+=i)
      if(!fs[j]) fs[j]=i;
  }

  vector<Int> cand;
  for(Int x:ans)
    for(Int y:ans)
      cand.emplace_back(x*y);

  cand.emplace_back(1);
  cand=compress(cand);

  Int n;
  cin>>n;
  n--;

  cout<<cand[n]<<newl;
  return 0;
}
0