結果

問題 No.376 立方体のN等分 (2)
ユーザー CleyLCleyL
提出日時 2023-11-06 22:55:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 394 bytes
コンパイル時間 791 ms
コンパイル使用メモリ 68,376 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-11-06 22:56:02
合計ジャッジ時間 32,290 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 WA -
testcase_02 AC 351 ms
4,348 KB
testcase_03 AC 750 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 35 ms
4,348 KB
testcase_10 AC 628 ms
4,348 KB
testcase_11 WA -
testcase_12 AC 300 ms
4,348 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 4,084 ms
4,348 KB
testcase_17 AC 295 ms
4,348 KB
testcase_18 WA -
testcase_19 AC 596 ms
4,348 KB
testcase_20 WA -
testcase_21 AC 4,564 ms
4,348 KB
testcase_22 AC 106 ms
4,348 KB
testcase_23 AC 4,845 ms
4,348 KB
testcase_24 AC 4,837 ms
4,348 KB
testcase_25 AC 107 ms
4,348 KB
testcase_26 TLE -
testcase_27 WA -
testcase_28 AC 106 ms
4,348 KB
testcase_29 WA -
testcase_30 AC 184 ms
4,348 KB
testcase_31 WA -
testcase_32 AC 179 ms
4,348 KB
testcase_33 AC 108 ms
4,348 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 278 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
int main(){
  long long n;cin>>n;
  long long ans = n-1;
  for(long long i = 2; n >= i*i; i++){
    ans = min(ans, (i-1)+(n/i-1));
    if(n%i == 0){
      long long m = n/i;
      for(long long j = i; m >= j*j; j++){
        if(m%j == 0){
          ans = min(ans, (i-1)+(j-1)+(m/j-1));
        }
      }
    }
  }
  cout << ans << " " << n-1 << endl;
}
0