結果

問題 No.80 四角形を描こう
ユーザー Grun1396Grun1396
提出日時 2017-02-28 19:46:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 1,003 bytes
コンパイル時間 593 ms
コンパイル使用メモリ 51,712 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-09-02 17:59:07
合計ジャッジ時間 1,483 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 1 ms
4,368 KB
testcase_03 AC 2 ms
4,372 KB
testcase_04 AC 1 ms
4,372 KB
testcase_05 AC 1 ms
4,372 KB
testcase_06 AC 1 ms
4,372 KB
testcase_07 AC 1 ms
4,372 KB
testcase_08 AC 1 ms
4,368 KB
testcase_09 AC 3 ms
4,372 KB
testcase_10 AC 4 ms
4,372 KB
testcase_11 AC 23 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

using namespace std;

int main(){
    int d;
    cin >> d;
    int width ,height;
    int max = 0;
    if(d < 4) {
        cout << 0 << endl;   
        return 0;
    }
    /*
        4以上であれば2増えるたびに幅、高さを1増やせる。
        2*(w+h) = len の条件化で
        w*hを最大化する問題。
    */
    int g = (d-d%2)/2;
//cout << "(d-d%2)/2:" << g << endl;
    for(int e = 0; e < (d-d%2)/2 - 1; e++){
    width = d - d%2 - 2*e;

        width -= 2;//幅
        height = 2;//高さ
        if(max < width * height/4){
            max = width * height/4;
        }
        while(width != 2){
 //           cout << width << "|" << height << endl;
            width -= 2;
            height += 2;
 //           cout << "size:" << width * height / 4<< endl;
            if(max < width * height / 4){
                max = width * height / 4;
            }
        }
 //       cout << e << endl;
    }

    cout << max << endl;

    return 0;
}
0