結果

問題 No.987 N×Mマス計算(基本)
ユーザー ks2mks2m
提出日時 2020-02-14 21:23:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 202 ms / 2,000 ms
コード長 757 bytes
コンパイル時間 2,246 ms
コンパイル使用メモリ 77,452 KB
実行使用メモリ 42,680 KB
最終ジャッジ日時 2024-04-16 01:25:49
合計ジャッジ時間 6,333 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
41,316 KB
testcase_01 AC 137 ms
41,540 KB
testcase_02 AC 174 ms
42,316 KB
testcase_03 AC 155 ms
41,636 KB
testcase_04 AC 165 ms
41,956 KB
testcase_05 AC 157 ms
41,820 KB
testcase_06 AC 164 ms
41,944 KB
testcase_07 AC 158 ms
41,772 KB
testcase_08 AC 143 ms
41,620 KB
testcase_09 AC 141 ms
41,192 KB
testcase_10 AC 151 ms
41,312 KB
testcase_11 AC 174 ms
42,248 KB
testcase_12 AC 188 ms
42,492 KB
testcase_13 AC 158 ms
41,780 KB
testcase_14 AC 148 ms
41,672 KB
testcase_15 AC 164 ms
41,904 KB
testcase_16 AC 197 ms
42,268 KB
testcase_17 AC 193 ms
42,328 KB
testcase_18 AC 180 ms
42,348 KB
testcase_19 AC 202 ms
42,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		String s = sc.next();
		long[] b = new long[m];
		for (int i = 0; i < b.length; i++) {
			b[i] = sc.nextLong();
		}
		long[] a = new long[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextLong();
		}
		sc.close();

		for (int i = 0; i < a.length; i++) {
			StringBuilder sb = new StringBuilder();
			for (int j = 0; j < b.length; j++) {
				if ("+".equals(s)) {
					sb.append(a[i] + b[j]).append(' ');
				} else {
					sb.append(a[i] * b[j]).append(' ');
				}
			}
			sb.deleteCharAt(sb.length() - 1);
			System.out.println(sb.toString());
		}
	}
}
0