結果

問題 No.988 N×Mマス計算(総和)
ユーザー htensaihtensai
提出日時 2020-02-21 08:27:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 797 ms / 2,000 ms
コード長 675 bytes
コンパイル時間 3,784 ms
コンパイル使用メモリ 72,604 KB
実行使用メモリ 64,736 KB
最終ジャッジ日時 2023-09-20 12:09:08
合計ジャッジ時間 11,807 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,740 KB
testcase_01 AC 127 ms
55,692 KB
testcase_02 AC 143 ms
56,084 KB
testcase_03 AC 142 ms
55,468 KB
testcase_04 AC 140 ms
56,064 KB
testcase_05 AC 149 ms
55,772 KB
testcase_06 AC 142 ms
55,624 KB
testcase_07 AC 143 ms
56,012 KB
testcase_08 AC 137 ms
56,076 KB
testcase_09 AC 139 ms
55,688 KB
testcase_10 AC 477 ms
60,252 KB
testcase_11 AC 598 ms
60,976 KB
testcase_12 AC 706 ms
63,732 KB
testcase_13 AC 520 ms
60,280 KB
testcase_14 AC 496 ms
60,620 KB
testcase_15 AC 507 ms
60,556 KB
testcase_16 AC 631 ms
61,964 KB
testcase_17 AC 696 ms
64,056 KB
testcase_18 AC 553 ms
60,576 KB
testcase_19 AC 735 ms
63,208 KB
testcase_20 AC 797 ms
64,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        char op = sc.next().charAt(0);
        long sumB = 0;
        for (int i = 0; i < m; i++) {
            sumB += sc.nextInt();
        }
        sumB %= k;
        long sumA = 0;
        for (int i = 0; i < n; i++) {
            sumA += sc.nextInt();
        }
        sumA %= k;
        if (op == '+') {
            System.out.println((sumA * m + sumB * n) % k);
        } else {
            System.out.println(sumA * sumB % k);
        }
    }
}
0