結果

問題 No.1058 素敵な数
ユーザー 👑 platinumplatinum
提出日時 2020-05-22 21:35:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 1,702 ms
コンパイル使用メモリ 169,476 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 16:11:58
合計ジャッジ時間 2,184 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

bool is_prime(LL p){
	for(LL i=2; i*i<=p; i++) if(p%i==0) return false;
	return true;
}

int main(){
	int N;
	cin >> N;
	vector<LL> p, ans;
	ans.emplace_back(1LL);
	LL num=1e5+1;
	while(1){
		if(is_prime(num)) p.emplace_back(num);
		num++;
		if(p.size()>=10) break;
	}
	rep(i,p.size()){
		for(int j=i; j<p.size(); j++) ans.emplace_back(p[i]*p[j]);
	}
	sort(ans.begin(),ans.end());
	cout << ans[N-1] << endl;

	return 0;
}
0