結果
| 問題 |
No.988 N×Mマス計算(総和)
|
| ユーザー |
kiefer_von_maus
|
| 提出日時 | 2020-02-28 23:50:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 688 bytes |
| コンパイル時間 | 1,692 ms |
| コンパイル使用メモリ | 167,332 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-06 07:32:26 |
| 合計ジャッジ時間 | 2,418 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n, m, k;
cin >> n >> m >> k;
char op;
cin >> op;
long long ans = 0;
long long a[n], b[m];
for(int i = 0; i < m; i++) {
cin >> b[i];
}
for(int i = 0; i < n; i++) {
cin >> a[i];
}
long long int c = 0, d = 0;
if(op == '+') {
for(int i = 0; i < n; i++) {
c += a[i];
c = c % k;
}
for(int i = 0; i < m; i++) {
d += b[i];
d = d % k;
}
ans = (c * m + d * n) % k;
}
if(op == '*') {
for(int i = 0; i < n; i++) {
c += a[i];
c = c % k;
}
for(int i = 0; i < m; i++) {
ans += c * b[i];
ans = ans % k;
}
}
cout << ans << endl;
}
kiefer_von_maus