結果
| 問題 |
No.375 立方体のN等分 (1)
|
| コンテスト | |
| ユーザー |
ngtkana
|
| 提出日時 | 2020-04-05 22:07:45 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 5,000 ms |
| コード長 | 962 bytes |
| コンパイル時間 | 2,007 ms |
| コンパイル使用メモリ | 199,468 KB |
| 最終ジャッジ日時 | 2025-01-09 14:24:46 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 32 |
ソースコード
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using lubl=long double;
void cmn(lint&x,lint y){if(x>y)x=y;}
void cmx(lint&x,lint y){if(x<y)x=y;}
int main(){
std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
lint n;std::cin>>n;
std::vector<lint>div;
for(lint i=1;i*i<=n;i++){
if(n%i)continue;
div.push_back(i);
if(i*i!=n)div.push_back(n/i);
}
std::sort(ALL(div));
lint min=std::numeric_limits<lint>::max();
lint sz=div.size();
for(lint i=0;i<sz;i++){
lint x=div.at(i);
if(n/x/x/x==0)break;
for(lint j=i;j<sz;j++){
lint y=div.at(j);
if(n/x/y/y==0)break;
if(n%(x*y))continue;
lint z=n/x/y;
assert(x<=y&&y<=z&&x*y*z==n);
cmn(min,x+y+z-3);
}
}
std::cout<<min<<' '<<n-1<<'\n';
}
ngtkana