結果

問題 No.987 N×Mマス計算(基本)
ユーザー TatsuyaaaaTatsuyaaaa
提出日時 2020-02-14 21:34:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 860 bytes
コンパイル時間 2,207 ms
コンパイル使用メモリ 74,552 KB
実行使用メモリ 42,616 KB
最終ジャッジ日時 2024-04-16 01:35:11
合計ジャッジ時間 5,926 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
41,184 KB
testcase_01 AC 129 ms
41,280 KB
testcase_02 AC 176 ms
42,112 KB
testcase_03 AC 143 ms
41,880 KB
testcase_04 AC 153 ms
41,836 KB
testcase_05 AC 156 ms
41,644 KB
testcase_06 AC 159 ms
41,632 KB
testcase_07 AC 144 ms
41,608 KB
testcase_08 AC 125 ms
41,196 KB
testcase_09 AC 134 ms
41,672 KB
testcase_10 AC 135 ms
41,588 KB
testcase_11 AC 178 ms
41,820 KB
testcase_12 AC 174 ms
42,616 KB
testcase_13 AC 150 ms
41,796 KB
testcase_14 AC 140 ms
41,588 KB
testcase_15 AC 148 ms
41,696 KB
testcase_16 AC 177 ms
41,472 KB
testcase_17 AC 182 ms
42,208 KB
testcase_18 AC 181 ms
41,856 KB
testcase_19 AC 193 ms
42,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        String S = sc.next();
        long[] B = new long[M];
        long[] A = new long[N];
        for (int i=0;i<M;i++) B[i] = sc.nextLong();
        for (int i=0;i<N;i++) A[i] = sc.nextLong();

        for (int i=0;i<N;i++) {
            StringBuilder sb = new StringBuilder();
            for (int j=0;j<M;j++) {
                long tmp = 0;
                if (S.charAt(0)=='+') {
                    tmp = A[i]+B[j];
                } else { // S.charAt(0)=='*'
                    tmp = A[i]*B[j];
                }
                sb.append(tmp);
                if (j!=M-1) sb.append(" ");
            }
            System.out.println(sb);
        }
    }
}
0