結果

問題 No.988 N×Mマス計算(総和)
ユーザー CELICA
提出日時 2020-08-05 15:19:26
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 541 bytes
コンパイル時間 1,583 ms
コンパイル使用メモリ 165,900 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-17 02:30:13
合計ジャッジ時間 3,130 ms
ジャッジサーバーID
(参考情報)
judge5 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using ll = long long;

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n,m,k;
    string op;
    cin >> n >> m >> k >> op;

    ll a,b,sa{0},sb{0},res;
    
    for (int i=0;i<m;++i)
    {
        cin >> b;
        sb+=b;
    }
    for (int i=0;i<n;++i)
    {
        cin >> a;
        sa+=a;
    }
    
    sa %= k;
    sb %= k;

    if (op == "+")
        res = (sa * m + sb * n) % k;
    else
        res = sa * sb % k;

    cout << res << "\n";

    return 0;
}
0