結果

問題 No.1058 素敵な数
ユーザー betit0919betit0919
提出日時 2020-05-22 21:25:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,172 bytes
コンパイル時間 1,319 ms
コンパイル使用メモリ 128,524 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 15:40:56
合計ジャッジ時間 1,858 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>
#include <iterator>
#include <functional>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

vector<bool> IsPrime;

void sieve(int max){
  if(max+1 > IsPrime.size()){
    IsPrime.resize(max+1,true);
  }
  IsPrime[0] = false;
  IsPrime[1] = false;

  for(int i=2; i*i<=max; ++i){
    if(IsPrime[i]){
      for(int j=2; i*j<=max; ++j){
        IsPrime[i*j] = false;
      }
    }
  }
}

int main()
{
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  sieve(200000);
  int N;cin>>N;
  if(N==1){
    cout<<1<<endl;
  }else{
    int cnt=1;
    for(int i=100001;i<200000;i++){
      if(IsPrime[i]){
        cnt++;
        if(cnt==N){
          cout<<i<<endl;
          break;
        }
      }
    }
  }
}
0