結果

問題 No.988 N×Mマス計算(総和)
ユーザー ks2mks2m
提出日時 2020-02-14 21:31:17
言語 Java19
(openjdk 21)
結果
AC  
実行時間 784 ms / 2,000 ms
コード長 774 bytes
コンパイル時間 3,073 ms
コンパイル使用メモリ 73,680 KB
実行使用メモリ 67,060 KB
最終ジャッジ日時 2023-09-20 11:33:41
合計ジャッジ時間 12,189 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,644 KB
testcase_01 AC 122 ms
55,860 KB
testcase_02 AC 140 ms
55,956 KB
testcase_03 AC 131 ms
55,716 KB
testcase_04 AC 134 ms
55,880 KB
testcase_05 AC 140 ms
56,052 KB
testcase_06 AC 139 ms
55,736 KB
testcase_07 AC 139 ms
55,700 KB
testcase_08 AC 132 ms
56,060 KB
testcase_09 AC 131 ms
55,828 KB
testcase_10 AC 464 ms
60,780 KB
testcase_11 AC 566 ms
60,432 KB
testcase_12 AC 702 ms
64,908 KB
testcase_13 AC 502 ms
60,704 KB
testcase_14 AC 486 ms
60,504 KB
testcase_15 AC 494 ms
60,612 KB
testcase_16 AC 615 ms
62,236 KB
testcase_17 AC 673 ms
64,704 KB
testcase_18 AC 541 ms
58,656 KB
testcase_19 AC 698 ms
62,880 KB
testcase_20 AC 784 ms
67,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		long[] b = new long[m];
		for (int i = 0; i < b.length; i++) {
			b[i] = sc.nextLong();
		}
		long[] a = new long[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextLong();
		}
		sc.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