結果

問題 No.988 N×Mマス計算(総和)
ユーザー keisuke6keisuke6
提出日時 2022-05-27 21:17:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 626 bytes
コンパイル時間 1,536 ms
コンパイル使用メモリ 169,476 KB
実行使用メモリ 4,876 KB
最終ジャッジ日時 2023-10-20 19:49:22
合計ジャッジ時間 4,128 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 28 ms
4,348 KB
testcase_14 WA -
testcase_15 AC 23 ms
4,348 KB
testcase_16 AC 48 ms
4,348 KB
testcase_17 AC 60 ms
4,612 KB
testcase_18 AC 36 ms
4,348 KB
testcase_19 AC 59 ms
4,348 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int N,M,K;
    cin>>N>>M>>K;
    swap(N,M);
    char a;
    cin>>a;
    vector<int> A(N),B(M);
    for(int i=0;i<N;i++) cin>>A[i];
    for(int i=0;i<M;i++) cin>>B[i];
    int ans = 0;
    if(a == '+'){
        for(int i=0;i<N;i++) ans += A[i]*M;
        for(int i=0;i<M;i++) ans += B[i]*N;
        cout<<ans%K<<endl;
    }
    else{
        for(int i=0;i<N;i++) ans += A[i];
        int sum = ans;
        ans = 0;
        for(int i=0;i<M;i++){
            ans += sum*B[i];
            ans %= K;
        }
        cout<<ans<<endl;
    }
}
0