結果
| 問題 | No.1058 素敵な数 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-08 23:27:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,109 bytes |
| コンパイル時間 | 2,573 ms |
| コンパイル使用メモリ | 176,196 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-26 19:08:13 |
| 合計ジャッジ時間 | 3,332 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
class sieve
{
protected:
int _n;
std::vector<bool> _f;
public:
sieve(int n) : _n(n), _f(n+1, true) {
_f[0] = false;
_f[1] = false;
for (int i = 4; i < _f.size(); i+=2)
_f[i] = false;
for (int i = 3; i*i < _f.size(); i+=2) {
if (!_f[i]) continue;
for (int j = i*i; j < _f.size(); j += i)
_f[j] = false;
}
}
bool isprime(int x) const { return _f[x]; }
int size() const { return _n; }
};
int main()
{
int N; cin >> N;
if (N == 1) {
cout << 1 << endl;
return 0;
}
sieve s(1e5+2000);
vector<int> primes;
for (int i = 1e5+1; i <= s.size(); i++) {
if (s.isprime(i)) primes.push_back(i);
if (primes.size() >= 10) break;
}
vector<ll> a;
for (int i = 0; i < primes.size() - 1; i++) {
for (int j = i+1; j < primes.size(); j++) {
a.push_back(primes[i] * primes[j]);
}
}
sort(a.begin(), a.end());
cout << a[N-2] << endl;
}