結果
| 問題 |
No.988 N×Mマス計算(総和)
|
| コンテスト | |
| ユーザー |
monnu
|
| 提出日時 | 2020-05-26 21:39:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 76 ms / 2,000 ms |
| コード長 | 730 bytes |
| コンパイル時間 | 1,249 ms |
| コンパイル使用メモリ | 168,776 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-06 07:45:15 |
| 合計ジャッジ時間 | 2,447 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
#define INF 1000000000000000000
#define MOD 1000000007
int main(){
int N,M,K;
char op;
cin>>N>>M>>K>>op;
vector<ll> A(N),B(M);
for(int i=0;i<M;i++){
cin>>B.at(i);
}
for(int i=0;i<N;i++){
cin>>A.at(i);
}
if(op=='*'){
ll sum1=0,sum2=0;
for(int i=0;i<N;i++){
sum1+=A.at(i);
}
for(int i=0;i<M;i++){
sum2+=B.at(i);
}
sum1%=K;
sum2%=K;
cout<<sum1*sum2%K<<endl;
}else{
ll ans=0;
for(int i=0;i<N;i++){
ans+=A.at(i)*(ll)M;
ans%=K;
}
for(int i=0;i<M;i++){
ans+=B.at(i)*(ll)N;
ans%=K;
}
cout<<ans<<endl;
}
}
monnu