結果

問題 No.988 N×Mマス計算(総和)
ユーザー tenten
提出日時 2020-08-24 21:09:08
言語 Java
(openjdk 23)
結果
AC  
実行時間 801 ms / 2,000 ms
コード長 706 bytes
コンパイル時間 2,005 ms
コンパイル使用メモリ 74,428 KB
実行使用メモリ 68,256 KB
最終ジャッジ日時 2024-11-06 10:41:46
合計ジャッジ時間 11,722 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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 = 0;
        for (int i = 0; i < m; i++) {
            colums += sc.nextInt();
            colums %= k;
        }
        long rows = 0;
        for (int i = 0; i < n; i++) {
            rows += sc.nextInt();
            rows %= k;
        }
        if (isPlus) {
            System.out.println((colums * n + rows * m) % k);
        } else {
            System.out.println(colums * rows % k);
        }
    }
}
0