結果

問題 No.988 N×Mマス計算(総和)
ユーザー rniya
提出日時 2020-03-06 23:59:52
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 592 bytes
コンパイル時間 1,275 ms
コンパイル使用メモリ 169,072 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-06 07:33:02
合計ジャッジ時間 2,189 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M; ll K; cin >> N >> M >> K;
    char op; cin >> op;
    vector<ll> A(N),B(M);
    for (int i=0;i<M;++i) cin >> B[i];
    for (int i=0;i<N;++i) cin >> A[i];
    ll ans=0;
    if (op=='+'){
        for (int i=0;i<N;++i) (ans+=A[i]*M%K)%=K;
        for (int i=0;i<M;++i) (ans+=B[i]*N%K)%=K;
    } else {
        ll sum=0;
        for (int i=0;i<M;++i) (sum+=B[i]%K)%=K;
        for (int i=0;i<N;++i) (ans+=A[i]*sum%K)%=K;
    }
    cout << ans << '\n';
}
0