結果
問題 | No.49 算数の宿題 |
ユーザー |
|
提出日時 | 2024-08-06 11:27:10 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 932 bytes |
コンパイル時間 | 14,731 ms |
コンパイル使用メモリ | 393,500 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-08-06 11:27:25 |
合計ジャッジ時間 | 13,605 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
コンパイルメッセージ
warning: unused imports: `BTreeSet`, `HashMap`, `HashSet` --> src/main.rs:1:24 | 1 | use std::collections::{BTreeSet, HashMap, HashSet}; | ^^^^^^^^ ^^^^^^^ ^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
ソースコード
use std::collections::{BTreeSet, HashMap, HashSet};use proconio::marker::Chars;fn main() {proconio::input! {s: Chars,}let op_indexes = s.iter().enumerate().filter(|(_, c)| !c.is_numeric()).map(|(i, _)| i).collect::<Vec<_>>();let mut values: Vec<i64> = vec![];let mut i = 0;for &op_index in op_indexes.iter() {values.push(s[i..op_index].iter().collect::<String>().parse().unwrap());i = op_index + 1;}values.push(s[i..].iter().collect::<String>().parse().unwrap());eprintln!("{:?}", values);let mut ans = values[0];for (i, op) in op_indexes.into_iter().map(|op_index| s[op_index]).enumerate(){match op {'+' => ans *= values[i + 1],'*' => ans += values[i + 1],_ => unreachable!(),}}println!("{}", ans);}