結果

問題 No.1058 素敵な数
ユーザー okok
提出日時 2020-05-22 21:34:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,283 bytes
コンパイル時間 844 ms
コンパイル使用メモリ 89,848 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 16:09:46
合計ジャッジ時間 1,390 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<set>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

// struct fast_io {
	// fast_io(){
		// std::cin.tie(nullptr);
		// std::ios::sync_with_stdio(false);
	// };
// } fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	const int NUM = 100000;
	vector<int> pn, temp;
	set<int> s;
	int x = 20;
	
	cin>>N;
	
	if(N == 1) {
		cout<<1<<endl;
		return 0;
	}
	
	N--;
	
	
	
	for(int i = NUM; ; i++){ //cout<<i<<" "<<N<<endl;
		int minimum = INF;
		bool flag = false;
		
		for(int j = 2; j * j <= i; j++){
			if(i%j == 0) {
				minimum = min(minimum, j);
				flag = true;
			}
		}
		
		// cout<<minimum<<endl;
		
		if(flag == false) {
			// N--;
			pn.push_back(i);
			if(pn.size() >= x) break;
		}
		
		// if(flag && minimum > NUM) {
			// N--;
		// }		
			
		// if(N == 0) {
			// cout<<i*i<<endl;
			// return 0;
		// }
		
		// break;
	}
	
	for(int i = 0; i < pn.size(); i++){
		for(int j = 0; j < pn.size(); j++){
			s.insert(pn[i] * pn[j]);
		}
	}
	
	for(int y : s){
		N--;
		if(N == 0) {
			cout<<y<<endl;
			break;
		}
	}
	
	
	return 0;
}
0