結果

問題 No.375 立方体のN等分 (1)
ユーザー Grun1396Grun1396
提出日時 2017-02-25 16:37:21
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,222 bytes
コンパイル時間 452 ms
コンパイル使用メモリ 59,408 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-02 08:04:50
合計ジャッジ時間 1,962 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <math.h>
#define INF 0x7FFFFFFF
using namespace std;


int main(){
    long long n;//立方体をn個の合同な直方体に分割したい。
    cin >> n;
/*
合同にするには必ず、X→Y→Z軸にそって等分していかないとだめでは?
三回だけしか等分割できない→
解き方:
Tmax = n-1なので、Tminが問題。
Tmin は N = abcと分解できる時の、
a + b + c -3 の最小値
ここでaは a * a * a <= Nを満たすはずなので総当りでも解けるということ。
*/
    long long Tmin = n-1,Tmax = n-1;
    long long a = 1, b = 1, c = 1;
int count = 0;
long long  tmp;
    for(a = cbrt(n)+1; c > 0; c--){
        //b,cを総当りする。bc = n/aとあらわせる。
        if(n % a != 0) continue;
        
        for(b = sqrt(n/a)+1; b > 0; b--){
            if((n/a) % b != 0) continue;
            tmp = a + b + n/a/b -3;
            cout << tmp << endl;
            if(tmp < Tmin){
                Tmin = tmp;
                cout  << count << "change" << endl;
            }
        }
    }

  
    cout << Tmin << " " << Tmax << endl;
    
    return 0;
}
/*
N = a*b*c において a+b+c-3の最小値を求める
*/
0