結果

問題 No.988 N×Mマス計算(総和)
ユーザー sosamjayososamjayo
提出日時 2020-03-27 03:53:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 1,750 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 79,988 KB
実行使用メモリ 5,028 KB
最終ジャッジ日時 2023-09-20 12:19:07
合計ジャッジ時間 2,173 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 24 ms
4,380 KB
testcase_11 AC 37 ms
4,376 KB
testcase_12 AC 62 ms
4,536 KB
testcase_13 AC 29 ms
4,380 KB
testcase_14 AC 27 ms
4,380 KB
testcase_15 AC 24 ms
4,376 KB
testcase_16 AC 50 ms
4,376 KB
testcase_17 AC 62 ms
4,548 KB
testcase_18 AC 35 ms
4,376 KB
testcase_19 AC 58 ms
4,480 KB
testcase_20 AC 86 ms
5,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




int main() {

    int n, m, k;
    cin >> n >> m >> k;
    char op; cin >> op;
    ll a[n], b[m];
    rep(i,m) cin >> b[i];
    rep(i,n) cin >> a[i];
    
    ll a_sum = 0;
    rep(i,n) a_sum = (a_sum + a[i]) % k;
    ll b_sum = 0;
    rep(i,m) b_sum = (b_sum + b[i]) % k;

    ll ans;
    if (op == '+') {
        ans = m * a_sum + n * b_sum;
        ans %= k;
    }
    else {
        ans = a_sum * b_sum;
        ans %= k;
    }
    out(ans);

    return 0;
}








0