結果

問題 No.933 おまわりさんこいつです
ユーザー phsplsphspls
提出日時 2020-01-25 21:47:59
言語 Rust
(1.77.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 741 bytes
コンパイル時間 690 ms
コンパイル使用メモリ 144,360 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-12 04:43:55
合計ジャッジ時間 1,888 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,352 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,352 KB
testcase_16 AC 3 ms
4,352 KB
testcase_17 AC 5 ms
4,352 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 6 ms
4,352 KB
testcase_20 AC 5 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
testcase_23 AC 11 ms
4,352 KB
testcase_24 AC 12 ms
4,352 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `n`
 --> Main.rs:7:9
  |
7 |     let n: u128 = all_data.iter().next().unwrap().parse::<u128>().unwrap();
  |         ^ help: if this is intentional, prefix it with an underscore: `_n`
  |
  = note: `#[warn(unused_variables)]` on by default

warning: 1 warning emitted

ソースコード

diff #

use std::io::Read;

fn main() {
    let mut all_data = String::new();
    std::io::stdin().read_to_string(&mut all_data).ok();
    let all_data: Vec<&str> = all_data.trim().split('\n').map(|a| a.trim()).collect();
    let n: u128 = all_data.iter().next().unwrap().parse::<u128>().unwrap();
    let mut result: u128 = 1;
    all_data.iter().skip(1).next().unwrap().split_whitespace()
        .map(|a| a.parse::<u128>().unwrap())
        .map(|a| if a == 0 { 0 } else if a % 9 == 0 { 9 } else { a % 9 })
        .for_each(|a| {
            result = if result * a == 0 { 0 } else if (result * a) % 9 == 0 { 9 } else { (result * a) % 9 };
        });

    println!("{}", if result == 0 { 0 } else if result % 9 == 0 { 9 } else { result % 9 });
}
0