結果

問題 No.1058 素敵な数
ユーザー oriekaorieka
提出日時 2020-05-26 02:46:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 898 bytes
コンパイル時間 1,186 ms
コンパイル使用メモリ 107,424 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 04:03:38
合計ジャッジ時間 1,597 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 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

template<typename T>
bool is_prime(T n) {
	for(int i = 2; i * i <= n; ++i) {
		if( n % i == 0 ) {
			return false;
		}
	}
	
	return true;
}

int main(void) {
	int n;
	cin >> n;
	
	ll x = 1e5;	
	vector<ll> primes;
	
	while( primes.size() <= 10 ) {
		if( is_prime(x) ) primes.push_back(x);
		
		x++;
	}
	
	vector<ll> ans;
	ans.push_back(1LL);
	
	for(int i = 0; i < primes.size(); ++i) {
		for(int j = i; j < primes.size(); ++j) {
			ans.push_back(primes[i] * primes[j]);
		}
	}
	
	sort(ans.begin(), ans.end());
	
	cout << ans[n - 1] << endl;
	
	return 0;
}
0