結果

問題 No.988 N×Mマス計算(総和)
ユーザー Mishan5055Mishan5055
提出日時 2020-02-25 16:53:33
言語 Java
(openjdk 23)
結果
AC  
実行時間 711 ms / 2,000 ms
コード長 868 bytes
コンパイル時間 1,931 ms
コンパイル使用メモリ 74,208 KB
実行使用メモリ 68,760 KB
最終ジャッジ日時 2024-07-06 07:31:31
合計ジャッジ時間 10,871 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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