結果

問題 No.810 割った余りの個数
コンテスト
ユーザー elphe
提出日時 2026-02-05 15:02:11
言語 Rust
(1.93.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 574 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 827 ms
コンパイル使用メモリ 194,624 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-02-05 15:02:14
合計ジャッジ時間 2,616 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

fn main() {
    let stdin = std::io::read_to_string(std::io::stdin()).unwrap();
    let mut stdin = stdin.split_ascii_whitespace();

    let l: u32 = stdin.next().unwrap().parse().unwrap();
    let r: u32 = stdin.next().unwrap().parse().unwrap();
    let m: u32 = stdin.next().unwrap().parse().unwrap();

    println!("{}", output(solve(l, r, m)));
}

fn solve(l: u32, r: u32, m: u32) -> u32 {
    if r >= l + m {
        m
    } else if l % m <= r % m {
        r % m - l % m + 1
    } else {
        m - (l % m - r % m - 1)
    }
}

fn output(ans: u32) -> u32 {
    ans
}
0