F. Succession Fixoracci
Topic links: https://ac.nowcoder.com/acm/contest/912/F
topic:
Dynamic programming (Dynamic programming, abbreviated dp) is a method to the original problem into sub-problems of a relatively simple way to solve complex problems through. For example, let's say 1 x step could climb stairs or two layers, the n-layer seek small x climb stairs there are several methods, can be calculated using dp: Fi disposed layer of smaller x i climb stairs there are several methods, the Fi = Fi-1 + Fi-2.
Small x is two and a half long practice acm trainees, like Hu mouth, dp, tree line. Miao Miao, no matter what the subject, no matter how difficult, can use the small x three things he likes AC.
You may not believe, but in fact a theorem of his mouth Hu: all topics, can be converted to operate on x number of columns. Dp long as the first subject of a number of columns corresponding to x, then tree line just to maintain what you can before. The following definitions are given x columns:
T0 = A
Tl B =
Tn of 1⊕Tn-2-= Tn of (n ≧ 2)
where ⊕ is the exclusive OR operation.
Now a small x has a value determined by a and b dp. Now you just find Tn
how much you can question head.
Description Input:
Input three positive integers a, b, n, have the meaning described in the subject.
Wherein 0≤a, b, n≤1018
output Description:
Output an integer Tn of
, on behalf of the former two as a, b, x the number of columns of the subscript n is a value at.
Example 1
Input
122
Output
3
Thinking
101 110 ——>011——>101——>110——>011......
XOR will find value there has been circulating section 3
Painting came out more than a few
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll a,b,n; cin>>a>>b>>n; ll cc[10]; cc[0]=a; cc[1]=b; cc[2]=a^b; cout<<cc[n%3]<<endl; return 0; }