結果

問題 No.598 オーバーフローファンタジー
ユーザー zaichu
提出日時 2017-11-24 23:11:32
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 577 bytes
コンパイル時間 1,978 ms
コンパイル使用メモリ 165,832 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-26 01:55:50
合計ジャッジ時間 3,522 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template <typename T>
T gcd(T x, T y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

template <typename T>
T lcm(T x, T y)
{
    if (x == 0 || y == 0)
        return 0;
    return x / gcd(x, y) * y;
}

int main()
{
    int N;
    cin >> N;
    int X;
    cin >> X;
    int A;
    cin >> A;
    int B;
    cin >> B;
    int ans1 = X / A;
    if (X % A != 0)
        ans1++;
    int ans2 = (pow(2, N - 1) - X) / B;

    if ((int)(pow(2, N - 1) - X) % B != 0)
        ans2++;

    cout << min(ans1, ans2) << endl;
}
0