結果

問題 No.1058 素敵な数
ユーザー leaf_1415leaf_1415
提出日時 2020-05-22 21:27:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 1,139 bytes
コンパイル時間 1,092 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 5,428 KB
最終ジャッジ日時 2024-04-15 15:46:18
合計ジャッジ時間 1,961 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

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

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	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());
	
	cin >> n;
	cout << vec[n-1] << endl;
	
	return 0;
}
0