結果
問題 | No.376 立方体のN等分 (2) |
ユーザー |
![]() |
提出日時 | 2023-03-28 21:29:21 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,453 bytes |
コンパイル時間 | 3,789 ms |
コンパイル使用メモリ | 144,452 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-20 10:03:51 |
合計ジャッジ時間 | 6,670 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 7 WA * 17 RE * 14 |
ソースコード
#include <cassert>#include <cmath>#include <algorithm>#include <iostream>#include <iomanip>#include <limits.h>#include <map>#include <queue>#include <string.h>#include <vector>using namespace std;typedef long long ll;class Prime {public:vector<ll> prime_list;const ll MAX_N = 100000;Prime() {bool checked[MAX_N + 1];memset(checked, false, sizeof(checked));for (ll i = 2; i <= MAX_N; ++i) {if (!checked[i]) {prime_list.push_back(i);for (ll j = i * i; j <= MAX_N; j += i) {checked[j] = true;}}}}map<ll, int> prime_division(ll n) {map<ll, int> res;for (ll i = 0; prime_list[i] <= sqrt(n); ++i) {ll p = prime_list[i];while (n % p == 0) {++res[p];n /= p;}}if (n != 1) {res[n] = 1;}return res;}bool is_prime(ll n) {if (n <= 1) return false;for (int i = 0; i < prime_list.size(); ++i) {if (n % prime_list[i]) return false;}return true;}};int main() {ll N;Prime prime;cin >> N;ll min_T = LLONG_MAX;ll max_T = N - 1;map<ll, int> res = prime.prime_division(N);for (auto &[a, cnt] : res) {for (auto &[b, cnt] : res) {if (N % (a * b) != 0) continue;ll c = N / (a * b);ll t = (a + b + c) - 3;min_T = min(min_T, t);}}cout << min_T << " " << max_T << endl;return 0;}