結果

問題 No.555 世界史のレポート
ユーザー hiyokko2hiyokko2
提出日時 2017-08-11 23:58:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,043 bytes
コンパイル時間 1,302 ms
コンパイル使用メモリ 157,420 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 23:59:13
合計ジャッジ時間 2,037 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,bg,ed) for(ll i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
#define int long long
using namespace std;
typedef long long ll;
typedef vector<vector<ll>> mat;
const int INF = 1e9;

int N;
int C, V;

//X:コピーの回数 Y:ペーストの回数 でN文字以上を作れるか
bool checkXY(int X, int Y)
{
    int tmp = min(X, Y);
    //int can = 1, clip = (X > 0 ? 1 : 0);
    int can = 1, clip = 0;

    REP(i,tmp) {
        can *= 2;
        clip = can / 2;
    }

    can += clip * (Y - tmp);

    return N <= can;
}

//vのコストで作れるか
bool checkV(int v)
{
    for (int x=1; x<=v/C; x++) {
        //if (v - C * x < 0) break;
        int y = (v - C * x) / V;

        if (checkXY(x, y)) return true;
    }

    return false;
}

signed main()
{
    cin >> N;
    cin >> C >> V;

    int lb = 0, ub = LONG_LONG_MAX;
    while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        if (checkV(mid)) ub = mid;
        else lb = mid;
    }

    cout << ub << endl;
}
0