結果

問題 No.375 立方体のN等分 (1)
ユーザー rapurasu
提出日時 2016-08-08 16:35:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2,016 ms / 5,000 ms
コード長 491 bytes
コンパイル時間 1,387 ms
コンパイル使用メモリ 159,068 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 07:21:44
合計ジャッジ時間 8,298 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

 #include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
int main(){
    long long N;
    cin>>N;
    long long ans=N-1;
    for(long long i=1;i<pow(N,1.0/3.0)+3;i++){
       if(N%i!=0)continue;
       if(i>N)continue;
       long long M=N/i;
       for(long long j=1;j<int(sqrt(N))+1;j++){
          if(M%j!=0)continue;
          long long L=M/j;
          ans=min(L+i+j-3,ans);
       }
    }
    cout<<ans<<" "<<N-1<<endl;
}
0