結果

問題 No.3157 Nabeatsu
ユーザー akkey
提出日時 2025-05-24 02:26:14
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 736 bytes
コンパイル時間 11,609 ms
コンパイル使用メモリ 400,852 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-24 02:26:29
合計ジャッジ時間 14,403 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::{input, marker::Chars};
fn main() {
    input! {
        n: Chars
    }
    let mut rem = 0;
    for (i, c) in n[..n.len() - 1].iter().copied().enumerate()  {
        if c == '3' {
            print!("{}", '2');
            for _ in i + 1..n.len() - 1 {
                print!("9")
            }
            if rem % 3 == 1 {
                println!("8");
            }
            else {
                println!("9");
            }
            return;
        }
        print!("{c}");
        rem += c as usize - '0' as usize;
        rem %= 3;
    }
    if rem % 3 == 0 {
        println!("{}", (n.last().copied().unwrap() as usize - '0' as usize - 1));
    } else {
        println!("{}", n.last().unwrap());
    }
}
0