結果

問題 No.988 N×Mマス計算(総和)
ユーザー LaikaLaika
提出日時 2020-02-14 22:58:23
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 1,915 ms
コンパイル使用メモリ 193,408 KB
最終ジャッジ日時 2025-01-09 00:29:04
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    
    cin.tie(0); ios::sync_with_stdio(0);
    ll n, m, k;
    cin >> n >> m >> k;
    
    string op; cin >> op;
    ll sa = 0, sb = 0;
    for(int i = 0; i < m; ++i) {
        ll b; cin >> b;
        sb += b % k;
        sb %= k;
    }
    for(int i = 0; i < n; ++i) {
        ll a; cin >> a;
        sa += a % k;
        sa %= k;
    }

    if(op == "+"){
        cout << (m*sa%k + n*sb%k)%k << '\n';
    }
    if(op == "*"){
        cout << sa*sb%k << '\n';
    }

    
    return 0;
}
0