結果

問題 No.1058 素敵な数
コンテスト
ユーザー betit0919
提出日時 2020-05-22 21:29:37
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,335 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,034 ms
コンパイル使用メモリ 156,720 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-10 06:03:40
合計ジャッジ時間 1,829 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:71:9: warning: ignoring return value of '_FIter std::unique(_FIter, _FIter) [with _FIter = __gnu_cxx::__normal_iterator<long long int*, vector<long long int> >]', declared with attribute 'nodiscard' [-Wunused-result]
   71 |   unique(ALL(ans));
      |   ~~~~~~^~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/algorithm:63,
                 from main.cpp:4:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algo.h:875:5: note: declared here
  875 |     unique(_ForwardIterator __first, _ForwardIterator __last)
      |     ^~~~~~

ソースコード

diff #
raw source code

#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;
  vector<ll> ans;
  ans.push_back(1);
  vector<ll> primes;
  int cnt=0;
  for(int i=100001;i<200000;i++){
    if(IsPrime[i]){
      cnt++;
      primes.push_back(i);
      if(cnt==N){
        break;
      }
    }
  }
  REP(i,primes.size()){
    REP(j,primes.size()){
      ans.push_back(primes[i]*primes[j]);
    }
  }
  sort(ALL(ans));
  unique(ALL(ans));
  cout<<ans[N-1]<<endl;
}
0