显示原始代码
#include <bits/stdc++.h>
#define LL long long
using namespace std;
#define il inline
#define rd read()
#define int long long
const int L = 1e5 + 10, lim = 1e6, inf = 1e9, mod = 1e9 + 7;
int a[L], n;
int sum[L], tim1[L], tim2[L];
il int read() {
int res = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-')
f = -1;
c = getchar();
}
while (c >= '0' && c <= '9') {
res = res * 10 + c - 48;
c = getchar();
}
return res * f;
}
signed main(void) {
n = rd;
tim1[0] = tim2[0] = tim1[n + 1] = tim2[n + 1] = 1;
for (int i = 1; i <= n; ++i) a[i] = rd, sum[i] = sum[i - 1] + a[i], tim1[i] = (tim1[i - 1] * a[i]) % mod;
for (int i = n; i >= 1; --i) tim2[i] = (a[i] * tim2[i + 1]) % mod;
for (int i = 1; i <= n; ++i) {
int A = sum[i - 1] - (sum[n] - sum[i]), B = (tim1[i - 1] * tim2[i + 1]) % mod;
printf("%lld %lld\n", A, B);
}
return 0;
}