Changchun University fourteenth Programming Contest F Successione di Fixoracci-- find the law && water problem

topic

link

Meaning of the questions: give the definition of x number of columns:

  • $T_0 = a$
  • $T_1 = b$
  • $T_n = T_{n-2} \bigoplus T_{n-1} $

$ N-seeking entry of $ ($ 0 \ leqslant a, b, c \ leqslant 10 ^ {18} $)

analysis

$ N $ is so big, that must be constant time complexity.

Hit the table to find the law, can be found circulating in Section 3.

Or directly derived, $ a \ bigoplus b = c, \ b \ bigoplus c = a, \ c \ bigoplus a = b $

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
ll a, b, n;

int main()
{
    scanf("%lld%lld%lld", &a, &b, &n);
    ll c = a ^ b;

    ll ans;
    if(n % 3 == 0)   ans = a;
    else if(n % 3 == 1)  ans = b;
    else  ans = c;
    printf("%lld\n", ans);

    return 0;
}

 

Guess you like

Origin www.cnblogs.com/lfri/p/11202529.html