結果

問題 No.1058 素敵な数
ユーザー kk
提出日時 2020-05-30 19:45:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 831 bytes
コンパイル時間 1,836 ms
コンパイル使用メモリ 169,856 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 12:40:36
合計ジャッジ時間 2,356 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++)
#define ALL(x) (x).begin(), (x).end()

const double PI = acos(-1);

bool isPrime(long long n) {
  if (n < 2) return false;
  if (n == 2) return true;
  if (n % 2 == 0) return false;
  
  for (long long i = 3; i * i <= n; i += 2)
    if (n % i == 0)
      return false;
  
  return true;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int p = 100000;
  vector<long long> v;
  while (v.size() < 10) {
    if (isPrime(p)) {
      v.push_back(p);
    }
    ++p;
  }

  vector<long long> ret(1, 1);
  REP (i, v.size()) REP (j, v.size()) ret.push_back(v[i] * v[j]);
  sort(ret.begin(), ret.end());
  
  int n;
  cin >> n;
  cout << ret[n-1] << endl;
  
  return 0;
}
0