結果
問題 | No.988 N×Mマス計算(総和) |
ユーザー |
![]() |
提出日時 | 2020-02-14 21:24:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 2,865 bytes |
コンパイル時間 | 2,297 ms |
コンパイル使用メモリ | 211,408 KB |
最終ジャッジ日時 | 2025-01-08 23:57:22 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 |
ソースコード
#pragma GCC optimize ("Ofast")#include<bits/stdc++.h>using namespace std;inline void rd(int &x){int k;int m=0;x=0;for(;;){k = getchar_unlocked();if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){k = getchar_unlocked();if(k<'0'||k>'9'){break;}x=x*10+k-'0';}if(m){x=-x;}}inline void rd(long long &x){int k;int m=0;x=0;for(;;){k = getchar_unlocked();if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){k = getchar_unlocked();if(k<'0'||k>'9'){break;}x=x*10+k-'0';}if(m){x=-x;}}inline void rd(char &c){int i;for(;;){i = getchar_unlocked();if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){break;}}c = i;}inline int rd(char c[]){int i;int sz = 0;for(;;){i = getchar_unlocked();if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){break;}}c[sz++] = i;for(;;){i = getchar_unlocked();if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){break;}c[sz++] = i;}c[sz]='\0';return sz;}inline void wt_L(char a){putchar_unlocked(a);}inline void wt_L(long long x){int s=0;int m=0;char f[20];if(x<0){m=1;x=-x;}while(x){f[s++]=x%10;x/=10;}if(!s){f[s++]=0;}if(m){putchar_unlocked('-');}while(s--){putchar_unlocked(f[s]+'0');}}int N;int M;int K;long long A[100000];long long B[100000];long long sa;long long sb;char op;int main(){long long res = 0;rd(N);rd(M);rd(K);rd(op);{int Lj4PdHRW;for(Lj4PdHRW=(0);Lj4PdHRW<(M);Lj4PdHRW++){rd(B[Lj4PdHRW]);}}{int e98WHCEY;for(e98WHCEY=(0);e98WHCEY<(N);e98WHCEY++){rd(A[e98WHCEY]);}}{int FmcKpFmN;long long xr20shxY;if(N==0){xr20shxY = 0;}else{xr20shxY = A[0];for(FmcKpFmN=(1);FmcKpFmN<(N);FmcKpFmN++){xr20shxY += A[FmcKpFmN];}}sa =xr20shxY% K;}{int KrdatlYV;long long ao_dF3pO;if(M==0){ao_dF3pO = 0;}else{ao_dF3pO = B[0];for(KrdatlYV=(1);KrdatlYV<(M);KrdatlYV++){ao_dF3pO += B[KrdatlYV];}}sb =ao_dF3pO% K;}if(op=='+'){res = M * sa + N * sb;}else{res = sa * sb;}res %= K;wt_L(res);wt_L('\n');return 0;}// cLay varsion 20200214-1// --- original code ---// int N, M, K; ll A[1d5], B[1d5];// ll sa, sb;// char op;// {// ll res = 0;// rd(N,M,K,op,B(M),A(N));// sa = sum(A(N)) % K;// sb = sum(B(M)) % K;// if(op=='+'){// res = M * sa + N * sb;// } else {// res = sa * sb;// }// res %= K;// wt(res);// }