結果
問題 | No.375 立方体のN等分 (1) |
ユーザー |
![]() |
提出日時 | 2016-06-04 22:50:00 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 113 ms / 5,000 ms |
コード長 | 853 bytes |
コンパイル時間 | 1,443 ms |
コンパイル使用メモリ | 160,288 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-11 20:48:18 |
合計ジャッジ時間 | 2,885 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 32 |
ソースコード
#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 _WIN32 ifstream cin("sample.in"); ofstream cout("sample.out"); #endif cin.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)+1; FOR(j, 1, sqrt2+1) if(rest%j == 0) { mi = min(mi, i + j + rest/j - 3); } } cout << mi << " " << n - 1 << endl; }