結果
問題 | No.1058 素敵な数 |
ユーザー | startcpp |
提出日時 | 2020-05-22 21:29:53 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 741 bytes |
コンパイル時間 | 815 ms |
コンパイル使用メモリ | 75,392 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-07-28 06:28:13 |
合計ジャッジ時間 | 1,553 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 3 ms
4,380 KB |
testcase_02 | AC | 3 ms
4,376 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #define int long long using namespace std; bool isPrime[200000]; vector<int> ps; signed main() { int n; cin >> n; if (n == 1) { cout << 1 << endl; return 0; } int i, j; for (i = 0; i < 200000; i++) isPrime[i] = true; isPrime[0] = isPrime[1] = false; for (i = 2; i < 200000; i++) { if (isPrime[i]) { for (j = 2 * i; j < 200000; j += i) { isPrime[j] = false; } } } for (i = 100001; ps.size() < 10; i++) { if (isPrime[i]) { ps.push_back(i); } } vector<int> vec; for (i = 0; i < ps.size(); i++) { for (j = 0; j < ps.size(); j++) { vec.push_back(ps[i] * ps[j]); } } sort(vec.begin(), vec.end()); cout << vec[n - 2] << endl; return 0; }