結果

問題 No.1058 素敵な数
ユーザー 山下山下
提出日時 2020-05-22 21:55:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,032 bytes
コンパイル時間 1,684 ms
コンパイル使用メモリ 167,708 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-15 16:42:30
合計ジャッジ時間 2,235 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
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;
typedef long long int ll;
ll mod = 1000000007;
double pi = 3.14159265358979;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  int n;
  cin >> n;
  if (n==1) cout << 1 <<endl;
  else {
    vector<ll> K(11);
    int k = 1;
    int p = 0;
    for (int i = 100001; i < 1000000; i++) {
      bool f = 1;
      for (int j = 2; j < 100001; j++) {
        if (i%j==0) {
          f = 0;
          break;
        }
      }
      if (f) {
        K[k-1] = i;
        k++;
      }
      if (k == 11 && k != 1) {
        p = i;
        break;
      }
    }
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    for (int i = 0; i < 10; i++) {
      for (int j = i; j < 10; j++) {
        pq.push(K[i]*K[j]);
      }
    }
    for (int i = 0; i < n; i++) {
      if (i == n-1) {
        printf("%lld\n", pq.top());
        break;
      }
      pq.pop();
    }
  }
}
0