結果
| 問題 | 
                            No.1058 素敵な数
                             | 
                    
| コンテスト | |
| ユーザー | 
                             risujiroh
                         | 
                    
| 提出日時 | 2020-05-22 22:30:26 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 4 ms / 2,000 ms | 
| コード長 | 912 bytes | 
| コンパイル時間 | 2,369 ms | 
| コンパイル使用メモリ | 203,632 KB | 
| 最終ジャッジ日時 | 2025-01-10 14:53:06 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 9 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif
vector<int> sieve(int n) {
  vector<bool> b(n / 3 + 1, true);
  vector<int> res{2, 3};
  for (int p = 5, d = 4; p * p <= n; p += d = 6 - d) if (b[p / 3])
    for (int i = p * p, di = p % 3 * 2 * p; i <= n; i += di = 6 * p - di)
      b[i / 3] = false;
  for (int p = 5, d = 4; p <= n; p += d = 6 - d) if(b[p / 3]) res.push_back(p);
  while (not res.empty() and res.back() > n) res.pop_back();
  return res;
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  auto ps = sieve(2e5);
  int s = lower_bound(begin(ps), end(ps), (int)1e5) - begin(ps);
  vector<long long> v{1};
  for (int j = 0; j < 10; ++j) {
    for (int i = 0; i <= j; ++i) {
      v.push_back((long long)ps[s + i] * ps[s + j]);
    }
  }
  sort(begin(v), end(v));
  int n;
  cin >> n;
  --n;
  cout << v[n] << '\n';
}
            
            
            
        
            
risujiroh