結果

問題 No.2787 グッドスタイン数列?
ユーザー maguroflymagurofly
提出日時 2024-06-14 23:05:54
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 664 bytes
コンパイル時間 16,656 ms
コンパイル使用メモリ 395,892 KB
実行使用メモリ 14,008 KB
最終ジャッジ日時 2024-06-14 23:06:15
合計ジャッジ時間 15,941 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,248 KB
testcase_02 WA -
testcase_03 AC 1 ms
5,248 KB
testcase_04 WA -
testcase_05 AC 1 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 0 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 1 ms
5,376 KB
testcase_12 WA -
testcase_13 AC 1 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 1 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 0 ms
5,376 KB
testcase_26 AC 3 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 TLE -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    proconio::input!(mut n: i64, mut b: i64, c: i64);
    let mut steps = 0i64;
    steps += 1;
    for _ in 0 .. c {
        steps += 1;
        if n == 0 {
            break;
        }
        steps += 1;
        n = g(b, n) - 1;
        b += 1;
        if n >= 1_000_000_000 {
            println!("Yes\nNo");
            return;
        }
    }
    println!("Yes\nYes\n{steps}");
}

fn g(b: i64, n: i64) -> i64 {
    if n < b || n >= 2_000_000_000 {
        n
    } else {
        let x = g(b, n / b);
        if x >= 2_000_000_000 {
            return x;
        } else {
            x.saturating_mul(b + 1).saturating_add(n % b)
        }
    }
}
0