- 2023tyoi0292 的博客
三点三线 I
- 2024-5-3 22:50:07 @
三点三线 I
思路:先讲一下结论:答案为$(1+2+……+a_1) \times (1+2+……+a_2) \times …… \times (1+2+……+a_n)$
首先先找一组数据:比如
3
2 2 3
然后把每组列出来:
第1组
1 1 1
1 1 2
1 1 3
和为1*1*(1+2+3)
第2组
1 2 1
1 2 2
1 2 3
和为1*2*(1+2+3)
第3组
2 1 1
2 1 2
2 1 3
和为2*1*(1+2+3)
第4组
2 2 1
2 2 2
2 2 3
和为2*2*(1+2+3)
求和之后就是
十年OI一场空,不开long long见祖宗
还有,要取模啊!!!(因为这玩意儿错了的我)
AC code
#include <iostream>
#include <cstdio>
#define ll long long
using namespace std;
const ll mod = 1e9 + 7;
ll a[1000005];
int main() {
freopen("linedotI.in", "r", stdin);
freopen("linedotI.out", "w", stdout);
ll n;
cin >> n;
for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
ll mul = 1;
for(int i = 1; i <= n; i++) {
mul = mul * ((1 + a[i]) * a[i] / 2 % mod) % mod;
}
cout << mul << endl;
return 0;
}