結果

問題 No.1058 素敵な数
ユーザー bonKotsubonKotsu
提出日時 2021-06-15 00:17:39
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 617 bytes
コンパイル時間 1,592 ms
コンパイル使用メモリ 171,168 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 14:25:50
合計ジャッジ時間 2,232 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 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 ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>

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

int main() {
  int n;
  cin >> n;
  if(n==1) {
    cout << 1 << endl;
    return 0;
  }

  int cnt = 0;
  int i = 100001;
  vector<ll> v(10);
  while (cnt < 10) {
    if (isPrime(i)) {
      v[cnt] = (ll)i;
      cnt++;
    }
    i++;
  }
  vector<ll> ans;
  rep(i,10)rep(j,10) ans.push_back(v[i]*v[j]);
  sort(ans.begin(), ans.end());
  cout << ans[n-2] << endl;

}
0