結果
問題 | No.376 立方体のN等分 (2) |
ユーザー |
![]() |
提出日時 | 2016-08-24 20:45:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3,299 ms / 5,000 ms |
コード長 | 562 bytes |
コンパイル時間 | 875 ms |
コンパイル使用メモリ | 75,720 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-08 02:10:27 |
合計ジャッジ時間 | 20,197 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> using namespace std; vector<long> func2(long n) { vector<long> res; for(long i=1; i*i<=n; ++i) { if (n%i) continue; res.push_back(i); if (n!=i*i) res.push_back(n/i); } return res; } int main() { long n; cin>>n; auto d=func2(n); sort(begin(d), end(d)); long res=n-1; for(auto& x: d) { for(auto& y: d) { if (n/x%y) continue; res=min(res, x-1+y-1+n/x/y-1); } } cout<<res<<' '<<n-1<<endl; }