結果

問題 No.2787 グッドスタイン数列?
ユーザー eve__fuyuki
提出日時 2024-06-14 23:21:13
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 830 bytes
コンパイル時間 2,157 ms
コンパイル使用メモリ 193,392 KB
最終ジャッジ日時 2025-02-21 22:27:01
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 45 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

long long gb(long long n, long long b) {
    if (n < b) {
        return n;
    }
    return gb(n / b, b) * (b + 1) + n % b;
}
int main() {
    fast_io();
    long long n, b, c;
    cin >> n >> b >> c;
    cout << "Yes" << endl;
    long long step = 1;
    while (true) {
        if (step > 1e7) {
            cout << "No" << endl;
            return 0;
        }
        step++;
        if (n == 0) {
            break;
        }
        if (n < b) {
            step += 2 * n;
            break;
        }
        n = gb(n, b) - 1;
        b++;
        step++;
    }
    if (step <= c) {
        cout << "Yes" << endl;
        cout << step << endl;
    } else {
        cout << "No" << endl;
    }
}
0