結果
| 問題 |
No.376 立方体のN等分 (2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-04-15 00:36:39 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,746 ms / 5,000 ms |
| コード長 | 1,111 bytes |
| コンパイル時間 | 1,850 ms |
| コンパイル使用メモリ | 172,552 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 19:51:30 |
| 合計ジャッジ時間 | 13,884 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 38 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
const ll INF = LLONG_MAX/3;
vector<ll> divisor(ll n){
vector<ll> ret;
for(ll i=1; i*i<=n; ++i){
if(n%i == 0){
ret.pb(i);
if(n/i != i) ret.pb(n/i);
}
}
sort(all(ret));
return ret;
}
int main(){
ll n;
cin >>n;
vector<ll> d = divisor(n);
int D = d.size();
ll ans = INF;
rep(i,D){
ll a = d[i];
ll x = n/a;
rep(j,i+1){
ll b = d[j];
if(x%b != 0) continue;
ll c = x/b;
ans = min(ans, a+b+c-3);
}
}
cout << ans << " " << n-1 << "\n";
return 0;
}