結果

問題 No.1058 素敵な数
ユーザー BEN2suzukaBEN2suzuka
提出日時 2020-05-31 16:26:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 585 bytes
コンパイル時間 1,670 ms
コンパイル使用メモリ 172,320 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 21:03:36
合計ジャッジ時間 2,395 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

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

int main() {
  int N; cin >> N;
  vector<long long> primes;
  for (int i = 100001; i <= 101000; i++) {
    if (isPrime(i)) primes.push_back(i);
  }
  vector<long long> ans;
  ans.push_back(1);
  for (int i = 0; i < 10; i++) {
    for (int j = i; j < 10; j++) {
      ans.push_back(primes.at(i) * primes.at(j));
    }
  }
  sort(ans.begin(), ans.end());
  cout << ans.at(N-1) << endl;
}
0