結果
| 問題 | 
                            No.1058 素敵な数
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-05-22 23:41:52 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,185 bytes | 
| コンパイル時間 | 978 ms | 
| コンパイル使用メモリ | 92,152 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-05 21:50:40 | 
| 合計ジャッジ時間 | 1,441 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 2 WA * 7 | 
ソースコード
#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++;
    }
    cout << ans[0] * ans[n - 2] << endl;
  }
  return 0;
}