結果

問題 No.988 N×Mマス計算(総和)
ユーザー Mishan5055Mishan5055
提出日時 2020-02-25 16:53:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 790 ms / 2,000 ms
コード長 868 bytes
コンパイル時間 3,195 ms
コンパイル使用メモリ 71,900 KB
実行使用メモリ 64,712 KB
最終ジャッジ日時 2023-09-20 12:11:41
合計ジャッジ時間 12,109 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,884 KB
testcase_01 AC 122 ms
55,952 KB
testcase_02 AC 137 ms
56,468 KB
testcase_03 AC 130 ms
55,956 KB
testcase_04 AC 129 ms
56,252 KB
testcase_05 AC 140 ms
55,840 KB
testcase_06 AC 139 ms
55,916 KB
testcase_07 AC 138 ms
55,820 KB
testcase_08 AC 134 ms
55,964 KB
testcase_09 AC 133 ms
55,964 KB
testcase_10 AC 468 ms
60,800 KB
testcase_11 AC 571 ms
60,324 KB
testcase_12 AC 719 ms
64,384 KB
testcase_13 AC 498 ms
60,248 KB
testcase_14 AC 499 ms
60,624 KB
testcase_15 AC 487 ms
60,452 KB
testcase_16 AC 617 ms
62,644 KB
testcase_17 AC 687 ms
64,712 KB
testcase_18 AC 548 ms
60,688 KB
testcase_19 AC 692 ms
63,540 KB
testcase_20 AC 790 ms
64,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class MAin{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        long N=sc.nextLong();
        long M=sc.nextLong();
        int K=sc.nextInt();
        String str=sc.next();
        long ANS=0L;
        long B_SUM=0L;
        
        if(str.equals("+")){
            for(int i=0;i<M;i++){
                ANS+=(N*sc.nextLong())%K;
                ANS=ANS%K;
            }
            for(int i=0;i<N;i++){
                ANS+=(M*sc.nextLong())%K;
                ANS=ANS%K;
            }
        }else{
            for(int i=0;i<M;i++){
                B_SUM+=sc.nextLong()%K;
                B_SUM=B_SUM%K;
            }
            for(int i=0;i<N;i++){
                ANS+=(sc.nextLong()*B_SUM)%K;
                ANS=ANS%K;
            }
        }
        
        System.out.println(ANS);
    }
}
0