結果

問題 No.988 N×Mマス計算(総和)
ユーザー tentententen
提出日時 2020-08-24 21:04:41
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 947 bytes
コンパイル時間 2,636 ms
コンパイル使用メモリ 73,820 KB
実行使用メモリ 41,680 KB
最終ジャッジ日時 2024-04-24 03:48:52
合計ジャッジ時間 8,885 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
41,416 KB
testcase_01 AC 133 ms
41,540 KB
testcase_02 AC 143 ms
41,524 KB
testcase_03 AC 145 ms
41,680 KB
testcase_04 AC 138 ms
41,292 KB
testcase_05 AC 149 ms
41,484 KB
testcase_06 AC 146 ms
41,492 KB
testcase_07 AC 145 ms
41,448 KB
testcase_08 AC 143 ms
41,484 KB
testcase_09 AC 145 ms
41,404 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.*;

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();
        boolean isPlus = (sc.next().charAt(0) == '+');
        long[] colums = new long[m];
        for (int i = 0; i < m; i++) {
            colums[i] = sc.nextInt();
        }
        int[] rows = new int[n];
        for (int i = 0; i < n; i++) {
            rows[i] = sc.nextInt();
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                long value;
                if (isPlus) {
                    value = colums[j] + rows[i];
                } else {
                    value = colums[j] * rows[i];
                }
                ans += (int)(value % k);
                ans %= k;
            }
        }
        System.out.println(ans);
    }
}
0