【2020杭电多校】 The Oculus【签到】

题意:
T组输入,给三个行数,每一行第一个数x(代表之后有长度为x的01串),0代表当前不存在第在第i位的菲薄那切数,1代表存在,问第一行累加的菲薄那切和*第二行的菲薄那切和与第三行修改哪一位后得到的菲薄那切和值相等。

思路:
(A*B)=C+f[k]
这不就是判断两个值是否相同???直接取模判断即可,当然也不需要取模,爆2^64次方就相当于对 2^64 取模,直接写就行

参考代码:

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll N = 2e6 + 5;
const ll maxn = 1e5 + 5;
ull dp[N];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    dp[1] = 1ull, dp[2] = 2ull;
    for (ull i = 3; i <N; i++)
        dp[i] = dp[i - 1] + dp[i - 2];
    ull t;
    cin >> t;
    while (t--)
    {
        ull a, b, c, res = 0, ans = 0, cra = 0, x;
        cin >> a;
        for (ull i = 1; i <= a; i++)
        {
            cin >> x;
            if (x == 1)
                res += dp[i];
        }
        cin >> b;
        for (ull i = 1; i <= b; i++)
        {
            cin >> x;
            if (x == 1)
                ans += dp[i];
        }
        cin >> c;
        for (ull i = 1; i <= c; i++)
        {
            cin >> x;
            if (x == 1)
                cra += dp[i];
        }
        ans *= res;
        ull j = 1;
        while (cra != ans-dp[j])
            j++;
        cout << j << endl;
    }
}

猜你喜欢

转载自blog.csdn.net/yangzijiangac/article/details/107568320