結果
問題 | No.1058 素敵な数 |
ユーザー | scol_kp |
提出日時 | 2020-05-22 21:42:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,428 bytes |
コンパイル時間 | 2,438 ms |
コンパイル使用メモリ | 198,240 KB |
最終ジャッジ日時 | 2025-01-10 14:35:15 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
#include <bits/stdc++.h> #define FASTIO using namespace std; using ll = long long; using Vi = vector<int>; using Vl = vector<ll>; using Pii = pair<int, int>; using Pll = pair<ll, ll>; constexpr int I_INF = numeric_limits<int>::max(); constexpr ll L_INF = numeric_limits<ll>::max(); //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% void solve() { ll N; cin >> N; Vl ps; for (ll x = 100001;; x++) { bool ok = true; for (ll y = 2; y * y <= x; y++) { if (x % y == 0) { ok = false; break; } } if (ok) { ps.emplace_back(x); } if (ps.size() == 10) { break; } } Vl vs; for (ll i = 0; i < 10; i++) { for (ll j = i; j < 10; j++) { vs.emplace_back(ps[i] * ps[j]); } } sort(vs.begin(), vs.end()); if (N == 1) { cout << 1 << endl; } else { cout << vs[N - 2] << endl; } } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% int main() { #ifdef FASTIO cin.tie(0), cout.tie(0); ios::sync_with_stdio(false); #endif #ifdef FILEINPUT ifstream ifs("./in_out/input.txt"); cin.rdbuf(ifs.rdbuf()); #endif #ifdef FILEOUTPUT ofstream ofs("./in_out/output.txt"); cout.rdbuf(ofs.rdbuf()); #endif solve(); cout << flush; return 0; }