結果

問題 No.376 立方体のN等分 (2)
ユーザー rapurasurapurasu
提出日時 2016-08-08 16:53:11
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 625 bytes
コンパイル時間 1,543 ms
コンパイル使用メモリ 160,980 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-24 22:14:14
合計ジャッジ時間 8,144 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 RE -
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 RE -
testcase_09 WA -
testcase_10 WA -
testcase_11 RE -
testcase_12 WA -
testcase_13 RE -
testcase_14 RE -
testcase_15 WA -
testcase_16 WA -
testcase_17 RE -
testcase_18 RE -
testcase_19 WA -
testcase_20 RE -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 RE -
testcase_26 WA -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 WA -
testcase_31 WA -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

 #include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long ll;
int main(){
    long long N;
    cin>>N;
    long long ans=N-1;
    vector<ll>v;
    for(ll i=1;i<10000001;i++){
        if(i*i>=N)break;
        if(N%i==0)v.push_back(i);
    }
    v.push_back(N);
    for(ll i=1;v[i]*v[i]*v[i]<=N;i++){
       if(N%v[i]!=0)continue;
       long long M=N/v[i];
       for(int j=1;v[i]*v[j]*v[j]<=N;j++){
          if(M%v[j]!=0)continue;
          long long L=M/j;
          ans=min(L+v[i]+v[j]-3,ans);
       }
    }
    cout<<ans<<" "<<N-1<<endl;
}
0