結果
問題 | No.1058 素敵な数 |
ユーザー | opt |
提出日時 | 2020-05-22 21:30:58 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,020 bytes |
コンパイル時間 | 3,201 ms |
コンパイル使用メモリ | 212,476 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-05 15:25:57 |
合計ジャッジ時間 | 3,103 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 5 ms
5,248 KB |
testcase_02 | AC | 5 ms
5,248 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using V = vector<int>; using Vll = vector<ll>; using Vld = vector<ld>; using Vbo = vector<bool>; using VV = vector<V>; using VVll = vector<Vll>; using VVld = vector<Vld>; using VVbo = vector<Vbo>; using P = pair<int, int>; using Pll = pair<ll, ll>; using Pld = pair<ld, ld>; #define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i) #define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i) #define rep(i, n) rep2(i, 0, n) #define drep(i, n) drep2(i, n, 0) #define all(a) a.begin(), a.end() struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; } template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; } template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; } template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; } template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r) inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits const int INF = 1<<30; const ll INFll = 1ll<<62; const ld EPS = 1e-10; const ld PI = acos(-1.0); const int MOD = int(1e9)+7; struct Eratos { vector<int> primes, min_factor; vector<bool> isprime; Eratos(int MAX) : primes(), isprime(MAX+1, true), min_factor(MAX+1, -1) { isprime[0] = isprime[1] = false; min_factor[0] = 0, min_factor[1] = 1; for (int i = 2; i <= MAX; i++) { if (!isprime[i]) continue; primes.push_back(i); min_factor[i] = i; for (int j = i*2; j <= MAX; j += i) { isprime[j] = false; if (min_factor[j] == -1) min_factor[j] = i; } } } // prime factorization vector<pair<int,int>> factorize(int n) { vector<pair<int,int>> res; while (n != 1) { int prime = min_factor[n]; int exp = 0; while (min_factor[n] == prime) { exp++; n /= prime; } res.push_back(make_pair(prime, exp)); } return res; } }; int main() { ll n; cin >> n; if (n == 1) { cout << 1 << "\n"; return 0; } Eratos E(int(2e5)); Vll p; rep2(i, 1e5, 2e5) { if (E.isprime[i]) p.push_back(i); if (p.size() == 10) break; } Vll q; rep(i, 10) rep(j, 10) q.push_back(p[i] * p[j]); sort(all(q)); ll ans = q[n-2]; cout << ans << "\n"; return 0; }