結果
問題 | No.988 N×Mマス計算(総和) |
ユーザー | fura |
提出日時 | 2020-02-14 22:15:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 33 ms / 2,000 ms |
コード長 | 490 bytes |
コンパイル時間 | 2,040 ms |
コンパイル使用メモリ | 194,456 KB |
最終ジャッジ日時 | 2025-01-09 00:18:21 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:14:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | rep(j,m) scanf("%lld",&b[j]), b[j]%=k; | ~~~~~^~~~~~~~~~~~~~ main.cpp:15:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | rep(i,n) scanf("%lld",&a[i]), a[i]%=k; | ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; using lint=long long; int main(){ int n,m; lint k; char op; cin>>n>>m>>k>>op; vector<lint> b(m),a(n); rep(j,m) scanf("%lld",&b[j]), b[j]%=k; rep(i,n) scanf("%lld",&a[i]), a[i]%=k; lint sum1=accumulate(a.begin(),a.end(),0LL)%k; lint sum2=accumulate(b.begin(),b.end(),0LL)%k; lint ans=0; if(op=='+') ans=(m*sum1+n*sum2)%k; else ans=sum1*sum2%k; printf("%lld\n",ans); return 0; }