結果

問題 No.1058 素敵な数
ユーザー 山下山下
提出日時 2020-05-22 22:01:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 1,049 bytes
コンパイル時間 1,564 ms
コンパイル使用メモリ 170,832 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-07-28 07:31:09
合計ジャッジ時間 2,343 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

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(10);
    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-1; i++) {
      if (i == n-2) {
        printf("%lld\n", pq.top());
        break;
      }
      pq.pop();
    }
  }
}
0