結果

問題 No.1058 素敵な数
ユーザー furafura
提出日時 2020-05-22 21:21:58
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 654 bytes
コンパイル時間 2,573 ms
コンパイル使用メモリ 200,588 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-15 15:34:15
合計ジャッジ時間 6,001 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

bool is_prime(long long a){
	if(a%2==0) return a==2;
	for(long long i=3;i*i<=a;i+=2) if(a%i==0) return false;
	return a!=1;
}

vector<long long> divisors(long long a){
	vector<long long> res;
	for(long long i=1;i*i<=a;i++) if(a%i==0) {
		res.emplace_back(i);
		if(i*i<a) res.emplace_back(a/i);
	}
	sort(res.begin(),res.end());
	return res;
}

int main(){
	int n; scanf("%d",&n);
	for(int i=1;;i++) if(!is_prime(i)) {
		bool ok=true;
		for(auto d:divisors(i)) if(2<=d && d<=1e5) ok=false;
		if(ok){
			n--;
			if(n==0) return printf("%d\n",i),0;
		}
	}
	return 0;
}
0