結果

問題 No.988 N×Mマス計算(総和)
ユーザー cra77756176
提出日時 2022-12-17 13:27:13
言語 Rust
(1.83.0 + proconio)
結果
TLE  
実行時間 -
コード長 732 bytes
コンパイル時間 15,494 ms
コンパイル使用メモリ 377,456 KB
実行使用メモリ 13,952 KB
最終ジャッジ日時 2024-11-16 21:52:48
合計ジャッジ時間 45,521 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 10 TLE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut xx = String::new();
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut xx).ok();
    let xx: Vec<&str> = xx.split_whitespace().collect();

    let m: usize = xx[1].parse().unwrap();
    let k: u64 = xx[2].parse().unwrap();
    let bb: Vec<u64> = xx[4..4 + m].iter().map(|&s| s.parse().unwrap()).collect();
    let aa: Vec<u64> = xx[4 + m..].iter().map(|&s| s.parse().unwrap()).collect();

    let op = match xx.get(3) {
        Some(&"+") => |a, b| a + b,
        Some(&"*") => |a, b| a * b,
        _ => unreachable!(),
    };

    let mut answer = 0;
    for a in &aa {
        for b in &bb {
            answer += op(a, b);
            answer %= k;
        }
    }

    println!("{answer}");
}
0