結果

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

テストケース

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

ソースコード

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()) FOR (j, i, 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