結果

問題 No.987 N×Mマス計算(基本)
ユーザー ixTL255ixTL255
提出日時 2023-01-03 11:19:40
言語 Rust
(1.77.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,072 bytes
コンパイル時間 5,957 ms
コンパイル使用メモリ 151,736 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 00:14:51
合計ジャッジ時間 3,139 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

warning: unused variable: `m`
 --> Main.rs:9:9
  |
9 |     let m: usize = s.next().unwrap().parse().unwrap();
  |         ^ help: if this is intentional, prefix it with an underscore: `_m`

warning: variable does not need to be mutable
  --> Main.rs:19:9
   |
19 |     let mut a = a.trim().split_whitespace();
   |         ----^
   |         |
   |         help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

warning: 3 warnings emitted

ソースコード

diff #

use std::io;
use std::io::Read;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).ok();
    let mut s = s.trim().split_whitespace();
    let n: usize = s.next().unwrap().parse().unwrap();
    let m: usize = s.next().unwrap().parse().unwrap();

    let mut b = String::new();
    io::stdin().read_line(&mut b).ok();
    let mut b = b.trim().split_whitespace();
    let op: char = b.next().unwrap().chars().nth(0).unwrap();
    let b: Vec<usize> = b.map(|e| e.parse().unwrap()).collect();

    let mut a = String::new();
    std::io::stdin().read_to_string(&mut a).ok();
    let mut a = a.trim().split_whitespace();
    let a: Vec<usize> = a.map(|e| e.parse().unwrap()).collect();
    
    for i in 0..a.len() {
        let mut tmp = Vec::<usize>::new();
        for j in 0..b.len() {
            if op == '+' {
                tmp.push(a[i] + b[j]);
            } else {
                tmp.push(a[i] * b[j]);
            }
        }
        println!("{}", tmp.iter().map(|e| e.to_string())
        	.collect::<Vec<String>>().join(" "));
    }
}
0