标签:href 枚举 max pid bre inf break efi bit
2020 Multi-University Training Contest 2 The Oculus
题解:
这个题目很简单,就直接枚举就可以了,算法就是哈希。
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = 2e6+10;
const int mod1 = 1e9+7;
const int mod2 = 998244353;
ll f1[maxn],f2[maxn];
void init(){
f1[1]=f2[1]=1,f1[2]=f2[2]=2;
for(int i=3;i<maxn;i++) {
f1[i]=(f1[i-1]+f1[i-2])%mod1;
f2[i]=(f2[i-1]+f2[i-2])%mod2;
}
}
int a[maxn];
int main(){
int t;
init();
scanf("%d",&t);
while(t--){
ll A1=0,A2=0,B1=0,B2=0;
int k;
scanf("%d",&k);
for(int j=1,x;j<=k;j++){
scanf("%d",&x);
if(x){
A1=(A1+f1[j])%mod1;
A2=(A2+f2[j])%mod2;
}
}
scanf("%d",&k);
for(int j=1,x;j<=k;j++){
scanf("%d",&x);
if(x){
B1 = (B1+f1[j])%mod1;
B2 = (B2+f2[j])%mod2;
}
}
ll ans1 = A1*B1%mod1,ans2 = A2*B2%mod2;
scanf("%d",&k);
ll C1 = 0,C2 = 0;
for(int i=1;i<=k;i++){
scanf("%d",&a[i]);
if(a[i]){
C1 = (C1+f1[i])%mod1;
C2 = (C2+f2[i])%mod2;
}
}
int pos = 0;
for(int i=1;i<=k;i++){
if(!a[i]){
ll res1 = (C1+f1[i])%mod1;
ll res2 = (C2+f2[i])%mod2;
if(res1==ans1&&res2==ans2){
pos = i;
break;
}
}
}
printf("%d\n",pos);
}
return 0;
}
2020 Multi-University Training Contest 2 [The Oculus]
标签:href 枚举 max pid bre inf break efi bit
原文地址:https://www.cnblogs.com/EchoZQN/p/13368828.html