結果

問題 No.1058 素敵な数
ユーザー platinum
提出日時 2020-05-22 21:35:40
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 563 bytes
コンパイル時間 1,469 ms
コンパイル使用メモリ 173,796 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-05 15:56:53
合計ジャッジ時間 1,938 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

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