比赛 ZLXOI2015Day2 评测结果 AAAAAAAAAA
题目名称 沼跃鱼数列变换 最终得分 100
用户昵称 ppfish 运行时间 0.023 s
代码语言 C++ 内存使用 1.17 MiB
提交时间 2015-10-30 20:20:07
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;

template<class T>inline void Read(T &x)
{
    int f = 1;
    char t = getchar();
    while (t < '0' || t > '9') {
        if (t == '-') f = -1;
        t = getchar();
    }
    x = 0;
    while (t >= '0' && t <= '9') {
        x = x * 10 + t - '0';
        t = getchar();
    }
    x *= f;
}

const int maxn = 100005;
const int modulo = 9999997;

int n, m, ln;
int A[maxn], B[maxn];
bool ban[maxn];

long long ans = 1, en;

void input()
{
    int x;
    Read(n);
    for (register int i = 1; i <= n; i++) Read(A[i]);
    Read(m);
    for (register int i = 1; i <= m; i++) Read(x), ban[x] = true;
    for (register int i = 1; i <= n; i++) if (!ban[i]) B[++ln] = A[i];
}

void solve()
{
    for (register int i = 1; i <= ln; i++) ans = 1ll * ans * (B[i] + 1) % modulo;
    en = ans;
    for (register int i = 1; i <= n; i++) {
        if (ban[i]) {
            ans = (ans + 1ll * en * A[i]) % modulo;
        }
    }
    ans = (ans - 1 + modulo) % modulo;
    cout << ans << endl;
}

int main()
{
    freopen("Marshtomp.in", "r", stdin);
    freopen("Marshtomp.out", "w", stdout);

    input();
    solve();
    
    fclose(stdin);
    fclose(stdout);
    return 0;
}