結果

問題 No.988 N×Mマス計算(総和)
ユーザー ParSAParSA
提出日時 2020-02-14 22:05:39
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 796 bytes
コンパイル時間 3,085 ms
コンパイル使用メモリ 73,708 KB
実行使用メモリ 69,084 KB
最終ジャッジ日時 2023-09-20 11:58:02
合計ジャッジ時間 7,535 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,960 KB
testcase_01 AC 120 ms
55,908 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 131 ms
55,956 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 138 ms
55,756 KB
testcase_08 AC 131 ms
55,708 KB
testcase_09 AC 132 ms
55,592 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int n = stdIn.nextInt(); //n行

		int m = stdIn.nextInt(); //m列
		
		int k = stdIn.nextInt(); //割る値

		String op = stdIn.next();

		int[] b = new int[m];

		for (int i = 0; i < m; i++) {
			b[i] = stdIn.nextInt();
		}

		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
		}
		
		long sum = 0;
		
		if(op.equals("+")) {
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < m; j++) {
					sum += a[i]+b[j];
				}
				
			}
			
			sum%=k;
			
		}else {
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < m; j++) {
					sum += (a[i] * b[j]) % k;
				}
			}
			sum %= k;
		}
		
		System.out.println(sum);
		
		
	}

}
0