結果

問題 No.1663 Maximum Remainder
ユーザー seinyan
提出日時 2021-10-28 21:42:57
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 612 bytes
コンパイル時間 14,845 ms
コンパイル使用メモリ 377,576 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-07 08:09:22
合計ジャッジ時間 13,089 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io;
fn main() {
    let nums = input_nums();
    let (_a, b, _c, d) = (nums[0], nums[1], nums[2], nums[3]);
    let m = nums[4];

    let mut max = b + d;

    if max < m {
        println!("{}", max);
        return;
    }

    max = 0;
    for i in (b + d - m)..(b + d) {
        if i % m > max {
            max = i % m;
        }
    }
    println!("{}", max);
}

fn input_nums() -> Vec<i32> {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    let mut v: Vec<i32> = Vec::new();
    for i in s.trim().split_whitespace() {
        v.push(i.parse().unwrap())
    }
    v
}
0