2018 ACM-ICPC Chinese College Students Programming Competition Online Competition

  •  512K

Description:

 
     
 
           
1
// Q.cpp
2
#include <iostream>
3
using namespace std;
4
const long long M = 1000000007;
5
const long long MAXL = 1000000;
6
long  long  a [ MAXL ];
7
long  long  Q ( int  n , long  long  t )
8
{
9
    if(n < 0) return t;
10
    return (Q(n - 1, t) + Q(n - 1, (t * a[n]) % M)) % M;
11
}
12
int main()
13
{
14
    int  n ;
15
    while(cin >> n)
16
    {
17
        for ( int  i  =  0 ; i  <  n ; ++ i )
18
        {
19
            cin >> a[i];
20
            a[i] %= M;
21
        }
22
        cout << Q(n - 1, 1) << endl;
23
    }
24
    return 0;
25
}

Input:

Input consists of several test cases. Each test case begins with an integer n. Then it's followed by n integers a[i]

0<n<=1000000

0<=a[i]<=10000

There are 100 test cases at most. The size of input file is less than 48MB. 

Output:

Maybe you can just copy and submit. Maybe not. 

sample input

1
233
1
666

Sample output

234
667

This question directly pastes the code it gives will cause the program memory overrun error, so you need to read the code it gives, the code seeks the n-term sequence, from 1 to the sum of the sum of any i-term combination after cumulative multiplication , for example, there are 3 items, the answer is 1+a[1] + a[2] + a[3] + a[1]*a[2]+a[1]*a[3]+a[2] *a[3] + a[1]*a[2]*a[3]

#include <bits/stdc++.h>

using namespace std;
typedef unsigned long long unll;
typedef  long long ll;
const int m = 1e9 + 7;
intmain()
{
    int n;
    ll a;
    ll ans;
    while(scanf("%d", &n) != EOF){
        years = 1;
        for(int i = 0; i < n; i ++){
            scanf("%lld", &a);
            years = years * (a + 1) % m;
            //cout << a[i] <<endl;
        }
        //cout << n << endl;
        printf("%lld\n", ans);
    }
    return 0;
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324701095&siteId=291194637