結果

問題 No.1058 素敵な数
ユーザー seven_threeseven_three
提出日時 2020-05-22 21:39:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 926 bytes
コンパイル時間 956 ms
コンパイル使用メモリ 100,284 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 16:18:36
合計ジャッジ時間 1,924 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long a[1000] = { 0 };
int main() {
	int co = 0;
	int n;
	cin >> n;
	for (long long i = 100001; i < 110000; i++) {
		bool b = true;
		for (long long j = 2; j * j < i; j++) {
			if (i % j == 0) {
				b = false;
			}
		}
		if (b == true) {
			a[co] = i;
			co++;
		}
	}
	vector<long long> vec;
	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 50; j++) {
			bool bo = true;
			for(int k=0;k<vec.size();k++){
				if (vec[k] == a[i] * a[j]) {
					bo = false;
				}
			}
			if (bo == true) {
				vec.emplace_back(a[i] * a[j]);
			}
		}
	}
	vec.emplace_back(1);
	sort(vec.begin(), vec.end());
	cout << vec[n - 1] << endl;
	return 0;
}
0