以下の内容はhttps://blog.hamayanhamayan.com/entry/2018/06/09/145117より取得しました。


四角形を描こう [yukicoder No.80]

https://yukicoder.me/problems/no/80

解説

https://yukicoder.me/submissions/264143

全探索できるものを探してみると、縦の長さが全探索できそうである。
縦の長さをhとすると、横の長さは可能な限り大きい方が良いので、wは(D - h * 2) / 2の切り捨てになる。
これでh*wの最大値が答えになる。

int D;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> D;

    int ans = 0;
    rep(h, 1, D + 1) {
        int w = (D - h * 2) / 2;
        chmax(ans, h * w);
    }
    cout << ans << endl;
}



以上の内容はhttps://blog.hamayanhamayan.com/entry/2018/06/09/145117より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14