結果
| 問題 | 
                            No.1058 素敵な数
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-05-23 00:05:00 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 5 ms / 2,000 ms | 
| コード長 | 1,419 bytes | 
| コンパイル時間 | 1,108 ms | 
| コンパイル使用メモリ | 99,216 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-05 23:13:40 | 
| 合計ジャッジ時間 | 1,669 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 9 | 
ソースコード
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
vector<bool> IsPrime;
void sieve(ll max) {
  if(max + 1 > IsPrime.size()) {   // resizeで要素数が減らないように
    IsPrime.resize(max + 1, true); // IsPrimeに必要な要素数を確保
  }
  IsPrime[0] = false; // 0は素数ではない
  IsPrime[1] = false; // 1は素数ではない
  for(ll i = 2; i * i <= max; ++i) {     // 0からsqrt(max)まで調べる
    if(IsPrime[i]) {                     // iが素数ならば
      for(ll j = 2; i * j <= max; ++j) { // (max以下の)iの倍数は
        IsPrime[i * j] = false;          // 素数ではない
      }
    }
  }
}
int main() {
  ll n;
  cin >> n;
  if(n == 1) {
    cout << 1 << endl;
  } else {
    int cnt = 0;
    vector<ll> ans;
    int a = 100000;
    sieve(1000000);
    while(cnt <= 10) {
      if(IsPrime[a]) {
        cnt++;
        ans.push_back(a);
      }
      a++;
    }
    map<ll, ll> mp;
    for(int i = 0; i < 10; i++) {
      for(int j = 0; j < 10; j++) {
        mp[ans[i] * ans[j]]++;
      }
    }
    cnt = 0;
    for(auto p : mp) {
      cnt++;
      if(n - 1 == cnt) {
        cout << p.first << endl;
        return 0;
      }
    }
  }
  return 0;
}