結果

問題 No.1058 素敵な数
ユーザー nsy_fuyansy_fuya
提出日時 2020-05-28 02:25:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 853 bytes
コンパイル時間 1,539 ms
コンパイル使用メモリ 169,984 KB
実行使用メモリ 5,536 KB
最終ジャッジ日時 2024-04-21 05:29:09
合計ジャッジ時間 2,093 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

bool prime[1000005];
vector<llint> pvec, vec;

void solve(){
    int n;
    cin >> n;
    for(int i = 2; i < 100005; i++){
		if(prime[i]) continue;
		for(int j = 2*i; j < 1000005; j+=i) prime[j] = true;
	}
    for(int i = 100001; i < 1000000; i++){
		if(!prime[i]) pvec.push_back(i);
	}
	vec.push_back(1);
	
	for(int i = 0; i < 20; i++){
		for(int j = 0; j < 20; j++){
			if(i > j) continue;
			vec.push_back(pvec[i]*pvec[j]);
		}
	}
	sort(vec.begin(), vec.end());
    cout << vec[n-1] << endl;
   
}

int main(){
  solve();
  return 0;
}
0