fork(4) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int Long;
  5. typedef long double Double;
  6. const int MAXN = 1e3 + 3;
  7. const Long MOD = 1006000007;
  8.  
  9. int t, n;
  10. Long a[MAXN], ans[MAXN];
  11.  
  12. int main() {
  13. scanf("%d", &t);
  14. for(int tc = 1; tc <= t; ++tc) {
  15. scanf("%d", &n);
  16. for(int i = 1; i <= n; ++i) {
  17. scanf("%lld", a + i);
  18. ans[i] = (ans[i - 1] + ans[i - 1] * a[i] + a[i]) % MOD;
  19. }
  20. printf("Case %d: %lld\n", tc, ans[n]);
  21. }
  22.  
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0.01s 15248KB
stdin
2
3
1 2 3
3
4 1 2
stdout
Case 1: 23
Case 2: 29