結果
問題 | No.376 立方体のN等分 (2) |
ユーザー |
![]() |
提出日時 | 2016-06-04 22:53:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 473 ms / 5,000 ms |
コード長 | 881 bytes |
コンパイル時間 | 1,318 ms |
コンパイル使用メモリ | 159,092 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-06 21:43:27 |
合計ジャッジ時間 | 5,772 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll; typedef long double ld;typedef vector<int> vi; typedef vector<ll> vl; typedef vector<bool> vb;typedef vector<double> vd;typedef vector<vd> vvd;#define REP(i,n) for(ll i=0; i < (n); ++i)#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)#define TEN(x) ((ll)1e##x)#define ALL(v) (v).begin(), (v).end()int main() {#ifdef _WIN32ifstream cin("sample.in");ofstream cout("sample.out");#endifcin.tie(0); // cinとcoutの連携を切るios_base::sync_with_stdio(false);cout << fixed << setprecision(50);ll n; cin >> n;ll sqrt3 = pow(n, 1.0 / 3) + 1;ll mi = n;FOR(i, 1, sqrt3+1) if (n%i == 0) {ll rest = n / i;ll sqrt2 = sqrt(rest) + 0.5;for (ll j = sqrt2; j >= 1; j--) if (rest%j == 0) {mi = min(mi, i + j + rest/j - 3);break;}}cout << mi << " " << n - 1 << endl;}