結果

問題 No.933 おまわりさんこいつです
ユーザー phsplsphspls
提出日時 2020-01-25 20:38:02
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 1,240 bytes
コンパイル時間 823 ms
コンパイル使用メモリ 154,884 KB
実行使用メモリ 8,696 KB
最終ジャッジ日時 2023-10-12 04:42:55
合計ジャッジ時間 5,432 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,532 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 1 ms
4,352 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 3 ms
4,352 KB
testcase_13 AC 49 ms
4,352 KB
testcase_14 AC 101 ms
4,352 KB
testcase_15 AC 485 ms
4,352 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `n`
 --> Main.rs:8:9
  |
8 |     let n: usize = all_data.iter().next().unwrap().parse::<usize>().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() {
    const DIVIDER: u128 = 1_000_000_000_000_000_000;
    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: usize = all_data.iter().next().unwrap().parse::<usize>().unwrap();
    let p: Vec<u128> = all_data.iter().skip(1).next().unwrap().split_whitespace().map(|a| a.parse::<u128>().unwrap()).collect();
    let mut result: Vec<u128> = vec![p[0]];
    p.iter().skip(1).for_each(|a| {
        let old = result.clone().to_owned();
        result.clear();
        let mut carry_over = 0;
        old.iter().for_each(|r| {
            let rest = (r * *a + carry_over) % DIVIDER;
            carry_over = (r * *a + carry_over) / DIVIDER;
            result.push(rest);
        });
        if carry_over > 0 {
            result.push(carry_over);
        }
    });
    let mut p: u128 = result.iter().map(|a| a.to_string().chars().map(|b| b.to_string().parse::<u128>().unwrap()).sum::<u128>()).sum();

    while p >= 10 {
        let p_str: String = p.to_string();
        p = p_str.chars().map(|a| a.to_string().parse::<u128>().unwrap()).sum();
    }
    println!("{}", p);
}
0