結果

問題 No.598 オーバーフローファンタジー
ユーザー 🍮かんプリン
提出日時 2019-03-19 20:16:09
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1,203 ms / 2,000 ms
コード長 497 bytes
コンパイル時間 669 ms
コンパイル使用メモリ 63,964 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-14 06:10:09
合計ジャッジ時間 3,630 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>

using ll = long long;
using namespace std;

const int MOD = 1e9+7;

int main() {
    int N, X, A, B, cnt1, cnt2;
    cnt1 = cnt2 = 0;
    cin >> N >> X >> A >> B;
    int x = X;
    while (!(x & (1<<(N-1)) || x == 0)) {
        x -= A;
        cnt1++;
    }
    x = X;
    while (!(x & (1<<(N-1)) || x == 0)) {
        x += B;
        cnt2++;
    }
    cout << min(cnt1, cnt2) << endl;
    return 0;
}
0