結果

問題 No.3035 2018
ユーザー okadukiokaduki
提出日時 2018-04-02 00:13:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 397 ms / 2,000 ms
コード長 2,122 bytes
コンパイル時間 2,139 ms
コンパイル使用メモリ 173,412 KB
実行使用メモリ 61,016 KB
最終ジャッジ日時 2023-09-08 13:08:00
合計ジャッジ時間 5,481 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 244 ms
61,016 KB
testcase_01 AC 241 ms
60,528 KB
testcase_02 AC 253 ms
60,792 KB
testcase_03 AC 376 ms
60,608 KB
testcase_04 AC 361 ms
60,084 KB
testcase_05 AC 397 ms
59,564 KB
testcase_06 AC 316 ms
59,968 KB
testcase_07 AC 236 ms
60,700 KB
testcase_08 AC 238 ms
59,940 KB
testcase_09 AC 246 ms
60,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

const int MAX = 16000000;
VL ps;
bool primes[MAX];

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  --N;

  fill(ALL(primes), true);
  primes[0] = primes[1] = false;
  for(int i=2;i<MAX;++i){
	if(primes[i]){
	  ps.PB(i);
	  for(int j=i+i;j<MAX;j+=i)
		primes[j] = false;
	}
  }

  using D = pair<LL,PII>;
  priority_queue<D,vector<D>,greater<D>> pq;
  REP(i,SZ(ps)-1){
	if(ps[i] < 2e6)
	  pq.push(MP(ps[i]*ps[i]*ps[i], MP(-1,-1)));
	pq.push(MP(ps[i]*ps[i+1], MP(i,i+1)));
  }

  while(N){
	--N;
	auto p = pq.top();
	pq.pop();
	if(p.SS.FF != -1){
	  if(p.SS.SS+1 < SZ(ps)){
		pq.push(MP(ps[p.SS.FF]*ps[p.SS.SS+1], MP(p.SS.FF, p.SS.SS+1)));
	  }
	}
  }
  cout << pq.top().FF << endl;
  
  return 0;
}
0