标签:stream clu while names mem 问题 iss 行数据 pac
3 1 2 3 2 2 4 1 3 4
62 0
这题就找规律。
但是挺难找的,耐心啊;
结果就是求(a1+b1)*(a2+b2)*....*(an+bn)-a1*a2...*an-b1*b2*...*bn
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #define mem(a) memset(a,0,sizeof(a)) 5 #define ll long long int 6 #define M 100005 7 #define Mod 1000000007 8 #define mem(a) memset(a,0,sizeof(a)) 9 using namespace std; 10 ll a[M],b[M],c[M]; 11 int main(){ 12 int n; 13 while(scanf("%d",&n)!=EOF){ 14 ll sum,cnt,ans; 15 sum=cnt=1; 16 ans=1; 17 for(int i=0;i<n;i++){ 18 scanf("%lld",&a[i]); 19 sum=(sum*a[i])%Mod; 20 c[i]=a[i]; 21 } 22 for(int i=0;i<n;i++){ 23 scanf("%lld",&b[i]); 24 cnt=(cnt*b[i])%Mod; 25 c[i]+=b[i]; 26 } 27 for(int i=0;i<n;i++){ 28 ans=(c[i]*ans)%Mod; 29 } 30 printf("%lld\n",(ans-cnt-sum+Mod+Mod)%Mod); 31 mem(a); 32 mem(b); 33 mem(c); 34 } 35 return 0; 36 }
标签:stream clu while names mem 问题 iss 行数据 pac
原文地址:http://www.cnblogs.com/zllwxm123/p/7260307.html