比赛 ZLXOI2015Day2 评测结果 AAAAAAAAAA
题目名称 沼跃鱼数列变换 最终得分 100
用户昵称 dashgua 运行时间 0.025 s
代码语言 C++ 内存使用 1.17 MiB
提交时间 2015-10-30 19:57:51
显示代码纯文本
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <iostream>
#include <algorithm>

template<class Num>void read(Num &x)
{
	char c; int flag = 1;
    while((c = getchar()) < '0' || c > '9')
		if(c == '-') flag *= -1;
	x = c - '0';
    while((c = getchar()) >= '0' && c <= '9')
		x = (x<<3) + (x<<1) + (c-'0');
	x *= flag;
	return;
}
template<class Num>void write(Num x)
{
	if(!x) {putchar('0');return;}
	if(x < 0) putchar('-'), x = -x;
	static char s[20];int sl = 0;
	while(x) s[sl++] = x%10 + '0',x /= 10;
    while(sl) putchar(s[--sl]);
}

const int maxn = 100050, Mod = 9999997;

int n, m, A[maxn], C[maxn];
bool hash[maxn];
long long ans = 1, cnt = 1;

int main()
{
	freopen("Marshtomp.in","r",stdin);
	freopen("Marshtomp.out","w",stdout);
	
	read(n);
	for(int i = 1; i <= n; i++) read(A[i]);
	read(m);
	for(int i = 1; i <= m; i++)
	{
		read(C[i]), hash[C[i]] = true;
		cnt += A[C[i]], cnt %= Mod;
	}
	
	for(int i = 1; i <= n; i++)
		if(!hash[i]) ans *= A[i] + 1, ans %= Mod;
	
	ans *= cnt, ans %= Mod;
	ans += Mod - 1, ans %= Mod;
	
	write(ans);
	
	fclose(stdin);
	fclose(stdout);
	return 0;
}