Submission #1209490
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
int mod = 1000000007;
int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
template<class... T> int add(int x, T... y) { return add(x, add(y...)); }
int mul(int x, int y) { return 1LL * x * y % mod; }
template<class... T> int mul(int x, T... y) { return mul(x, mul(y...)); }
int sub(int x, int y) { return add(x, mod - y); }
int modpow(int a, long long b) {
int ret = 1;
while (b > 0) {
if (b & 1) ret = 1LL * ret * a % mod;
a = 1LL * a * a % mod; b >>= 1;
}
return ret;
}
int modinv(int a) { return modpow(a, mod - 2); }
int fac[201010], ifac[201010];
void initfac() {
fac[0] = ifac[0] = 1;
rep(i, 1, 201010) fac[i] = 1LL * i * fac[i - 1] % mod;
rep(i, 1, 201010) ifac[i] = modinv(fac[i]);
}
int aCb(int a, int b) {
if (b < 0 || a < b) return 0;
return (1LL * fac[a] * ifac[a - b] % mod) * ifac[b] % mod;
}
int N, M, X[101010], Y[101010];
//-----------------------------------------------------------------------------------
int smx, smy;
int x[101010], y[101010];
int dpx[101010], dpy[101010];
void calc_sm() {
rep(i, 0, N - 1) x[i] = (X[i + 1] - X[i]) % mod;
rep(i, 0, M - 1) y[i] = (Y[i + 1] - Y[i]) % mod;
dpx[0] = x[0];
rep(i, 1, N - 1) dpx[i] = add(dpx[i - 1], mul(i + 1, x[i]));
rep(i, 0, N - 1) smx = add(smx, dpx[i]);
dpy[0] = y[0];
rep(i, 1, M - 1) dpy[i] = add(dpy[i - 1], mul(i + 1, y[i]));
rep(i, 0, M - 1) smy = add(smy, dpy[i]);
}
//-----------------------------------------------------------------------------------
int main() {
initfac();
cin >> N >> M;
rep(i, 0, N) scanf("%d", &X[i]);
rep(i, 0, M) scanf("%d", &Y[i]);
calc_sm();
cout << mul(smx, smy) << endl;
}
Submission Info
Submission Time |
|
Task |
D - ### |
User |
hamayanhamayan |
Language |
C++14 (GCC 5.4.1) |
Score |
500 |
Code Size |
1854 Byte |
Status |
AC |
Exec Time |
143 ms |
Memory |
4224 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:55:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep(i, 0, N) scanf("%d", &X[i]);
^
./Main.cpp:56:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep(i, 0, M) scanf("%d", &Y[i]);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
500 / 500 |
Status |
|
|
Set Name |
Test Cases |
Sample |
0_000.txt, 0_001.txt |
All |
0_000.txt, 0_001.txt, max.txt, min.txt, mod.txt, n2.txt, rndA.txt, rndB.txt, rndC.txt, rndD.txt, rndE.txt, rndF.txt, rndG.txt, rndH.txt, rndI.txt, rndJ.txt, var.txt |
Case Name |
Status |
Exec Time |
Memory |
0_000.txt |
AC |
116 ms |
1792 KB |
0_001.txt |
AC |
116 ms |
1792 KB |
max.txt |
AC |
143 ms |
4224 KB |
min.txt |
AC |
116 ms |
1792 KB |
mod.txt |
AC |
130 ms |
2944 KB |
n2.txt |
AC |
130 ms |
3072 KB |
rndA.txt |
AC |
143 ms |
4224 KB |
rndB.txt |
AC |
143 ms |
4224 KB |
rndC.txt |
AC |
143 ms |
4224 KB |
rndD.txt |
AC |
143 ms |
4224 KB |
rndE.txt |
AC |
143 ms |
4224 KB |
rndF.txt |
AC |
143 ms |
4224 KB |
rndG.txt |
AC |
143 ms |
4224 KB |
rndH.txt |
AC |
143 ms |
4224 KB |
rndI.txt |
AC |
143 ms |
4224 KB |
rndJ.txt |
AC |
143 ms |
4224 KB |
var.txt |
AC |
143 ms |
4224 KB |