結果
問題 | No.376 立方体のN等分 (2) |
ユーザー |
![]() |
提出日時 | 2016-06-04 22:59:36 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 575 ms / 5,000 ms |
コード長 | 598 bytes |
コンパイル時間 | 1,440 ms |
コンパイル使用メモリ | 162,144 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-06 21:44:03 |
合計ジャッジ時間 | 9,096 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long int64;vector< int64 > divisor(int64 n){vector< int64 > ll;for(int64 i = 1; i * i <= n; i++) {if(n % i == 0) {ll.push_back(i);if(i != n / i) ll.push_back(n / i);}}return(ll);}int main(){int64 N;cin >> N;auto p = divisor(N);int64 ret = N - 1;for(auto k : p) {int64 sub = N / k;for(int64 l = sqrt(sub); l >= 1; l--) {if(sub % l == 0) {ret = min(ret, k + l + sub / l - 3);break;}}}cout << ret << " " << N - 1 << endl;}