結果

問題 No.1010 折って重ねて
ユーザー yomo3
提出日時 2020-06-08 23:03:23
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 784 ms / 2,000 ms
コード長 493 bytes
コンパイル時間 2,137 ms
コンパイル使用メモリ 165,908 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-26 17:40:05
合計ジャッジ時間 5,150 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int dfs(ll x, ll y, ll h)
{
    if ((x & 1) || (y & 1)) {
        x <<= 1;
        y <<= 1;
        h <<= 1;
    }

    int a1 = 0, a2 = 0;
    if (x > h) {
        a1 = 1 + dfs(x/2, y, h*2);
    }
    if (y > h) {
        a2 = 1 + dfs(x, y/2, h*2);
    }
    return max(a1, a2);
}

int main()
{
    ll x, y, h;
    cin >> x >> y >> h;
    x *= 1000;
    y *= 1000;

    int ans = dfs(x, y, h);

    cout << ans << endl;
}
0