結果

問題 No.988 N×Mマス計算(総和)
ユーザー ParSAParSA
提出日時 2020-02-14 22:10:30
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 808 bytes
コンパイル時間 2,117 ms
コンパイル使用メモリ 73,596 KB
実行使用メモリ 56,240 KB
最終ジャッジ日時 2023-09-20 11:58:43
合計ジャッジ時間 8,287 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,672 KB
testcase_01 AC 121 ms
55,512 KB
testcase_02 AC 137 ms
55,932 KB
testcase_03 AC 131 ms
56,080 KB
testcase_04 AC 130 ms
55,604 KB
testcase_05 AC 137 ms
55,512 KB
testcase_06 AC 138 ms
55,452 KB
testcase_07 AC 140 ms
55,452 KB
testcase_08 AC 130 ms
56,240 KB
testcase_09 AC 132 ms
55,920 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 += (long)a[i]+b[j];
				}
				
			}
			
			sum%=k;
			
		}else {
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < m; j++) {
					sum += ((long)a[i] * b[j]) % k;
				}
			}
			sum %= k;
		}
		
		System.out.println(sum);
		
		
	}

}
0