結果

問題 No.1862 Copy and Paste
コンテスト
ユーザー vjudge1
提出日時 2024-11-26 14:52:12
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,935 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,591 ms
コンパイル使用メモリ 254,184 KB
実行使用メモリ 9,280 KB
最終ジャッジ日時 2026-07-06 04:57:18
合計ジャッジ時間 3,556 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 24 WA * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:67:46: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   67 |         ::ans = min(::ans, (__)a * i + (__)b * ans);
      |                                        ~~~~~~^~~~~
main.cpp:54:31: note: 'ans' was declared here
   54 |         ll l = i, r = n, mid, ans;
      |                               ^~~

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#ifndef LOCAL
#define file_name ""
#define csf                                                                               \
    {                                                                                     \
        std::cerr.setstate(std::ios_base::failbit);                                       \
        if (file_name != "")                                                              \
            freopen(file_name ".in", "r", stdin), freopen(file_name ".out", "w", stdout); \
    }
#define db(x)
#else
#define db(x) cerr << __FUNCTION__ << " L" << __LINE__ << " " << #x " = " << (x) << endl
#define csf
#endif
#define ll long long
#define unordered_map __gnu_pbds::gp_hash_table
#define f(x, y, z) for (ll x = (y); x <= (z); x++)
inline ll read();
using namespace std;
using __ = __int128;
const long long INF = 0x3f3f3f3f3f3f3f3f, M = 65;
ll n, a, b;
__ ans = INF;

bool check(ll x, ll y)
{ //?????
    ll a = y / x, b = y % x;

    __ res = 1;
    f(i, 1, x - b)
    {
        res *= a + 1;
        if (res > 1e18)
            return 1;
    }
    f(i, 1, b)
    {
        res *= a + 2;
        if (res > 1e18)
            return 1;
    }
    return res >= n;
}
signed main()
{
    csf;
    cin>>a>>b>>n;
    n++;

    f(i, 1, 65)
    { //?????

        ll l = i, r = n, mid, ans;
        while (l <= r)
        {
            mid = (l + r) / 2;
            if (check(i, mid))
            {
                ans = mid;
                r = mid - 1;
            }
            else
                l = mid + 1;
        }

        ::ans = min(::ans, (__)a * i + (__)b * ans);
    }
    cout << (ll)ans << endl;
    return 0;
}
/*
?????????

??????

????? 1 ????????? 3 ????23??????

????????????????w????v????????????v/w?????

???k???

???? x + k * y???? k + 1

x = 3, y = 1


k = 3

4 / 6

6 / 8

---------------

???????

???????

??????

???????????
*/
0