AC了好吧
2023-07-19 16:00:29
发布于:上海
38阅读
0回复
0点赞
#include<cstdio>
#define ll long long
#define maxn 111111
#define mod 10007
#pragma GCC optimize(3,"Ofast","inline")
inline ll read(){
ll r=0,f=1;
char c=getchar();
while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
while(c>='0'&&c<='9')r=(r<<1)+(r<<3)+(c^48),c=getchar();
return r*f;
}
int n,m,num[maxn],col[maxn];
ll ans,s_c[maxn][2][4];
int main(){
n=read(),m=read();
for(int i=1;i<=n;i++)num[i]=read()%mod;
for(int i=1;i<=n;i++)col[i]=read()%mod;
for(int i=1;i<=n;i++){//记得每一步都取模哦
(ans+=(s_c[col[i]][i%2][0]*(i%mod)*(num[i]%mod))%mod)%=mod;
(ans+=s_c[col[i]][i%2][1])%=mod;
(ans+=((i%mod)*s_c[col[i]][i%2][2])%mod)%=mod;
(ans+=((num[i]%mod)*s_c[col[i]][i%2][3])%mod)%=mod;
(s_c[col[i]][i%2][0]+=1)%=mod;
(s_c[col[i]][i%2][1]+=(i%mod)*(num[i]%mod))%=mod;
(s_c[col[i]][i%2][2]+=num[i]%mod)%=mod;
(s_c[col[i]][i%2][3]+=i%mod)%=mod;
}
printf("%lld",ans);
return 0;
}
这里空空如也
有帮助,赞一个