結果
| 問題 | No.376 立方体のN等分 (2) |
| コンテスト | |
| ユーザー |
fiord
|
| 提出日時 | 2016-07-16 19:11:30 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 611 bytes |
| 記録 | |
| コンパイル時間 | 567 ms |
| コンパイル使用メモリ | 67,608 KB |
| 実行使用メモリ | 10,020 KB |
| 最終ジャッジ日時 | 2024-10-15 13:53:10 |
| 合計ジャッジ時間 | 11,194 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 2 |
| other | WA * 14 TLE * 1 -- * 23 |
ソースコード
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
vector<ll> list;
int main() {
ll n; cin >> n;
for (ll i = 1; i*i <= n; i++) if (n%i == 0) list.push_back(i);
//(a+1)(b+1)(c+1)=Nを満たす中でのa+b+cの最小値
ll ans = 1e15;
for (ll a = 0; a < list.size(); a++) {
for (ll b = 0; b < list.size() && list[a] * list[b] <= n; b++) {
ll c = distance(list.begin(), find(list.begin(), list.end(), n / list[a] / list[b]));
ans = min(list[a] + list[b] + list[c] - 3, ans);
}
}
cout << ans << " " << n - 1 << endl;
return 0;
}
fiord