2020 Multi-University Training Contest 2 [The Oculus]

Posted echozqn

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了2020 Multi-University Training Contest 2 [The Oculus]相关的知识,希望对你有一定的参考价值。

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
",pos);
    }
    return 0;
}

以上是关于2020 Multi-University Training Contest 2 [The Oculus]的主要内容,如果未能解决你的问题,请参考以下文章

2020 Multi-University Training Contest 3

2020 Multi-University Training Contest 3 1004 Tokitsukaze and Multiple

2020 Multi-University Training Contest 1 1005 ( HDU 6755 ) Fibonacci Sum

2020 Multi-University Training Contest 1 . Fibonacci Sum 水题改编

2020 Multi-University Training Contest 1-1004 Distinct Sub-palindromes

2020 Multi-University Training Contest 2 - E. New Equipments(网络流)