結果

問題 No.988 N×Mマス計算(総和)
ユーザー ks2mks2m
提出日時 2020-02-14 21:37:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 301 ms / 2,000 ms
コード長 982 bytes
コンパイル時間 3,380 ms
コンパイル使用メモリ 74,144 KB
実行使用メモリ 64,724 KB
最終ジャッジ日時 2023-09-20 11:38:08
合計ジャッジ時間 6,601 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,156 KB
testcase_01 AC 42 ms
49,548 KB
testcase_02 AC 45 ms
49,236 KB
testcase_03 AC 45 ms
49,408 KB
testcase_04 AC 45 ms
49,312 KB
testcase_05 AC 46 ms
47,216 KB
testcase_06 AC 45 ms
49,324 KB
testcase_07 AC 46 ms
49,340 KB
testcase_08 AC 45 ms
49,264 KB
testcase_09 AC 46 ms
49,752 KB
testcase_10 AC 176 ms
55,616 KB
testcase_11 AC 218 ms
60,200 KB
testcase_12 AC 260 ms
62,896 KB
testcase_13 AC 220 ms
61,248 KB
testcase_14 AC 208 ms
60,368 KB
testcase_15 AC 142 ms
54,928 KB
testcase_16 AC 238 ms
60,168 KB
testcase_17 AC 262 ms
63,072 KB
testcase_18 AC 221 ms
60,700 KB
testcase_19 AC 263 ms
62,740 KB
testcase_20 AC 301 ms
64,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		int k = Integer.parseInt(sa[2]);
		sa = br.readLine().split(" ");
		String s = sa[0];
		long[] b = new long[m];
		for (int i = 0; i < b.length; i++) {
			b[i] = Long.parseLong(sa[i + 1]);
		}
		long[] a = new long[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = Long.parseLong(br.readLine());
		}
		br.close();

		long ans = 0;
		long suma = 0;
		for (int i = 0; i < a.length; i++) {
			suma += a[i];
		}
		long sumb = 0;
		for (int i = 0; i < b.length; i++) {
			sumb += b[i];
		}
		suma %= k;
		sumb %= k;
		if ("+".equals(s)) {
			ans = suma * m + sumb * n;
		} else {
			ans = suma * sumb;
		}
		ans %= k;
		System.out.println(ans);
	}
}
0