結果

問題 No.988 N×Mマス計算(総和)
ユーザー joybeeeejoybeeee
提出日時 2020-05-15 20:20:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 835 ms / 2,000 ms
コード長 626 bytes
コンパイル時間 2,986 ms
コンパイル使用メモリ 71,552 KB
実行使用メモリ 65,004 KB
最終ジャッジ日時 2023-09-20 12:25:24
合計ジャッジ時間 12,408 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,924 KB
testcase_01 AC 125 ms
55,820 KB
testcase_02 AC 142 ms
55,812 KB
testcase_03 AC 134 ms
55,804 KB
testcase_04 AC 134 ms
56,076 KB
testcase_05 AC 142 ms
55,828 KB
testcase_06 AC 142 ms
55,904 KB
testcase_07 AC 142 ms
56,160 KB
testcase_08 AC 135 ms
55,856 KB
testcase_09 AC 134 ms
56,100 KB
testcase_10 AC 505 ms
60,704 KB
testcase_11 AC 581 ms
60,644 KB
testcase_12 AC 757 ms
64,796 KB
testcase_13 AC 527 ms
60,272 KB
testcase_14 AC 517 ms
60,312 KB
testcase_15 AC 520 ms
60,376 KB
testcase_16 AC 651 ms
61,964 KB
testcase_17 AC 708 ms
64,740 KB
testcase_18 AC 546 ms
60,668 KB
testcase_19 AC 707 ms
63,780 KB
testcase_20 AC 835 ms
65,004 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 = 0L;
      for(int i = 0; i < m; i++)
      	sumB = (sumB + sc.nextInt()) % k;

      long res = 0L;
      if(op == '+') {
      	for(int i = 0; i < n; i++)
      		res = (res + sc.nextLong() * m % k + sumB) % k;
      } else {
      	for(int i = 0; i < n; i++)
      		res = (res + sc.nextLong() * sumB % k) % k;
      }

      System.out.println(res);
  }
}
0