結果

問題 No.988 N×Mマス計算(総和)
ユーザー 37zigen37zigen
提出日時 2020-02-14 21:45:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 778 ms / 2,000 ms
コード長 742 bytes
コンパイル時間 2,450 ms
コンパイル使用メモリ 74,036 KB
実行使用メモリ 66,596 KB
最終ジャッジ日時 2023-09-20 11:44:42
合計ジャッジ時間 11,560 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,904 KB
testcase_01 AC 117 ms
55,916 KB
testcase_02 AC 136 ms
56,264 KB
testcase_03 AC 131 ms
55,764 KB
testcase_04 AC 126 ms
55,468 KB
testcase_05 AC 135 ms
55,944 KB
testcase_06 AC 139 ms
56,136 KB
testcase_07 AC 140 ms
56,016 KB
testcase_08 AC 131 ms
55,480 KB
testcase_09 AC 133 ms
55,960 KB
testcase_10 AC 474 ms
60,808 KB
testcase_11 AC 571 ms
60,608 KB
testcase_12 AC 704 ms
64,812 KB
testcase_13 AC 515 ms
60,696 KB
testcase_14 AC 502 ms
60,296 KB
testcase_15 AC 522 ms
60,204 KB
testcase_16 AC 619 ms
61,756 KB
testcase_17 AC 711 ms
65,088 KB
testcase_18 AC 526 ms
60,680 KB
testcase_19 AC 670 ms
63,528 KB
testcase_20 AC 778 ms
66,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		long K=sc.nextLong();
		char op=sc.next().toCharArray()[0];
		long[] A=new long[N];
		long[] B=new long[M];
		for(int i=0;i<M;++i)B[i]=sc.nextLong();
		for(int i=0;i<N;++i)A[i]=sc.nextLong();
		long sa=0,sb=0;
		for(int i=0;i<N;++i) {sa+=A[i];sa%=K;}
		for(int i=0;i<M;++i) {sb+=B[i];sb%=K;}
		if(op=='+') {
			System.out.println((M*sa%K+N*sb%K)%K);
		}else {
			System.out.println(sa*sb%K);
		}
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}
0