結果

問題 No.987 N×Mマス計算(基本)
ユーザー rymg111
提出日時 2020-09-22 21:45:55
言語 Java
(openjdk 23)
結果
AC  
実行時間 324 ms / 2,000 ms
コード長 767 bytes
コンパイル時間 2,207 ms
コンパイル使用メモリ 77,564 KB
実行使用メモリ 58,112 KB
最終ジャッジ日時 2024-06-26 21:23:39
合計ジャッジ時間 7,649 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int raws = sc.nextInt();
		int columns = sc.nextInt();
		String op = sc.next();
		long[] rawNum = new long[raws];
		long[] colNum = new long[columns];
		for(int i = 0; i < columns; i++) {
			colNum[i] = sc.nextInt();
		}
		for(int j = 0; j < raws; j++) {
			rawNum[j] = sc.nextInt();
		}
		for(int k = 0; k < raws; k++) {
			for(int l = 0; l < columns; l++) {
				calculate(op, rawNum[k], colNum[l]);
				System.out.print(" ");
			}
			System.out.println("");
		}
	}
	public static void calculate(String op, long raw, long col) {
		if(op.equals("*")) {
			System.out.print(raw * col);
		} else {
			System.out.print(raw + col);
		}
	}
}
0