text
stringlengths
49
983k
#include <bits/stdc++.h> long long mx(long long a, long long b) { if (a > b) return a; else return b; } long long min(long long a, long long b) { if (a > b) return b; else a; } int main() { long long a, b, c, t; scanf("%lld", &t); while (t--) { scanf("%lld %lld %lld", &a, &b, &c); if (c == 0) printf("%lld\n", a); else if (c == 1) printf("%lld\n", b); else { if (c % 3 == 0) printf("%lld\n", a); else if (c % 3 == 1) printf("%lld\n", b); else printf("%lld\n", a ^ b); } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b, n; cin >> a >> b >> n; int c = a ^ b; if (n % 3 == 0) cout << a; else if (n % 3 == 1) cout << b; else cout << c; cout << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; inline void import(int& a) { scanf("%d", &a); } inline void import(int& a, int& b, int& c) { scanf("%d%d%d", &a, &b, &c); } inline void import(int& a, int& b) { scanf("%d%d", &a, &b); } const int maxn = 2e5 + 10, INF = 0x3f3f3f3f; int main() { int T, n, f[3]; import(T); while (T--) { import(f[0], f[1], n); f[2] = f[0] ^ f[1]; printf("%d\n", f[n % 3]); } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 100; long long f[N]; int main() { int t; cin >> t; while (t--) { long long a, b, n; cin >> a >> b >> n; f[0] = a, f[1] = b; for (int i = 2; i <= 4; i++) f[i] = f[i - 1] ^ f[i - 2]; cout << f[n % 3] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int t; cin >> t; while (t--) { long long int a, b, n, p; cin >> a >> b >> n; p = a ^ b; if (n % 3 == 0) cout << a << endl; else if ((n - 1) % 3 == 0) cout << b << endl; else cout << p << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t, a[3]; cin >> t; while (t--) { int n; cin >> a[0] >> a[1] >> n; a[2] = a[1] ^ a[0]; cout << a[n % 3] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 6; int a[4], n; int main() { int T; cin >> T; while (T--) { cin >> a[0] >> a[1] >> n; a[2] = a[0] ^ a[1]; cout << a[n % 3] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long a, b, n; cin >> a >> b >> n; long long c = (a ^ b); if (n % 3 == 0) cout << a << endl; if (n % 3 == 1) cout << b << endl; if (n % 3 == 2) cout << c << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long a, b, c, d; cin >> a >> b >> c; d = a ^ b; if ((c + 1) % 3 == 0) { cout << d << endl; } else if ((c + 1) % 3 == 1) { cout << a << endl; } else { cout << b << endl; } } return 0; }
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; int func(int a, int b, int n) { if (n == 0) return a; if (n == 1) return b; if (n % 3 == 2) return a ^ b; if (n % 3 == 0) return 0 ^ a; if (n % 3 == 1) return 0 ^ b; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t, a, b, n; cin >> t; for (int i = 0; i < t; i++) { cin >> a >> b >> n; cout << func(a, b, n) << '\n'; } }
#include <bits/stdc++.h> using namespace std; const int maxn = 2e5 + 5; const int maxm = 1e6 + 5; const long long INF = 0x3f3f3f3f3f3f3f3f; const long long mod = 1e9 + 7; int t, a, b, c, n; int main() { cin >> t; while (t--) { cin >> a >> b >> n; c = a ^ b; if ((n + 1) % 3 == 1) cout << a << endl; else if ((n + 1) % 3 == 2) cout << b << endl; else cout << c << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; for (int i = 0; i < T; i++) { int a, b, n, c = 0; cin >> a >> b >> n; if (n % 3 == 0) cout << a << endl; else if (n % 3 == 1) cout << b << endl; else { vector<int> A; int a1 = a; while (a1 > 0) { A.push_back(a1 % 2); a1 /= 2; } vector<int> B; int b1 = b; while (b1 > 0) { B.push_back(b1 % 2); b1 /= 2; } int e = 1, u = 0; for (int j = 0; j < min(A.size(), B.size()); j++) { if (A[j] + B[j] == 1) c += e; e *= 2; u++; } for (int r = u; r < max(A.size(), B.size()); r++) { if (A.size() > B.size() && A[r] % 2 == 1 || A.size() < B.size() && B[r] % 2 == 1) c += e; e *= 2; } cout << c << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; long long a, b, n; int main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); long long t; scanf("%I64d", &t); while (t--) { scanf("%I64d%I64d%I64d", &a, &b, &n); if (n == 0) printf("%I64d\n", a); else if (n == 1) printf("%lld\n", b); else { long long x = a ^ b; if (n % 3 == 0) printf("%I64d\n", a); else if (n % 3 == 1) printf("%I64d\n", b); else if (n % 3 == 2) printf("%I64d\n", x); } } }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int t, a, b, x; cin >> t; while (t--) { cin >> a >> b >> x; if (x % 3 == 0) cout << a << '\n'; else if (x % 3 == 1) cout << b << '\n'; else { x = a ^ b; cout << x << '\n'; } } }
#include <bits/stdc++.h> using namespace std; void solve() { int n; vector<int> v(3); cin >> v[0] >> v[1] >> n; v[2] = v[0] ^ v[1]; cout << v[n % 3] << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; cin >> t; while (t--) solve(); }
#include <bits/stdc++.h> using namespace std; int main() { cin.sync_with_stdio(0); cin.tie(0); cout.tie(0); int T; cin >> T; while (T--) { int a, b, k; cin >> a >> b >> k; if (k % 3 == 2) { cout << (a ^ b) << "\n"; } else if (k % 3 == 0) { cout << a << "\n"; } else { cout << b << "\n"; } } }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long t; cin >> t; while (t--) { long long a, b, n; cin >> a >> b >> n; if (n % 3 == 0) cout << a << "\n"; else if (n % 3 == 1) cout << b << "\n"; else if (n % 3 == 2) cout << (a ^ b) << "\n"; } }
#include <bits/stdc++.h> using namespace std; int main() { long long t, a, b, n, ans, c; cin >> t; while (t--) { cin >> a >> b >> n; c = a ^ b; n = n % 3; if (n == 0) ans = a; if (n == 1) ans = b; if (n == 2) ans = c; cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; ifstream in; ofstream out; const long long kk = 1000; const long long ml = kk * kk; const long long mod = ml * kk + 7; const long long inf = ml * ml * ml + 7; long long n, i, j; vector<long long> m; bool viv = false; void solve() { long long a, b, n; cin >> a >> b >> n; n %= 3; if (n == 0) return void(cout << a << endl); if (n == 1) return void(cout << b << endl); if (n == 2) return void(cout << (a ^ b) << endl); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t; cin >> t; while (t--) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); int t; int n; int ans[3]; cin >> t; while (t--) { cin >> ans[0] >> ans[1] >> n; ans[2] = ans[0] ^ ans[1]; cout << ans[n % 3] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { std::ios::sync_with_stdio(false); long long int t; cin >> t; while (t--) { long long int a, b, y; cin >> a >> b >> y; long long int x = y % 3LL; if (x == 0) { cout << a << endl; } else if (x == 1) cout << b << endl; else cout << (a xor b) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int t, n, a, b; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> t; while (t--) { cin >> a >> b >> n; if (n % 3 == 0) cout << a << '\n'; else if (n % 3 == 1) cout << b << '\n'; else cout << (a ^ b) << '\n'; } }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t) { vector<int> vi(3); int a, b, n; cin >> a >> b >> n; int c = a ^ b; vi[0] = a; vi[1] = b; vi[2] = c; int idx = n % 3; cout << vi[idx] << "\n"; t--; } }
#include <bits/stdc++.h> using namespace std; long long t, a, b, n; signed main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> t; while (t--) { long long a, b, n; cin >> a >> b >> n; ++n; if (n % 3 == 1) cout << a << '\n'; if (n % 3 == 2) cout << b << '\n'; if (n % 3 == 0) cout << (a ^ b) << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; long long int inf = 1e9 + 7; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int t; cin >> t; while (t--) { long long int a, b, n; cin >> a >> b >> n; if (n % 3 == 0) cout << a; else if (n % 3 == 1) cout << b; else { long long int ans = a ^ b; cout << ans; } cout << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int t, a, b, n; inline int read() { int x = 0; char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x; } int main() { t = read(); while (t > 0) { --t; a = read(); b = read(); n = read(); n %= 3; if (n == 0) printf("%d", a); else if (n == 1) printf("%d", b); else printf("%d", a ^ b); printf("\n"); } return 0; }
#include <bits/stdc++.h> using namespace std; int T; int main() { cin >> T; while (T--) { int a, b, n; cin >> a >> b >> n; n %= 3; if (n == 0) cout << a << endl; else if (n == 1) cout << b << endl; else cout << (a ^ b) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> struct rge { T b, e; }; template <class T> rge<T> range(T i, T j) { return rge<T>{i, j}; } struct debug { template <class T> debug& operator<<(const T&) { return *this; } }; using ll = long long; template <typename T> void min_self(T& a, T b) { a = min(a, b); } template <typename T> void max_self(T& a, T b) { a = max(a, b); } void test_case() { int a, b, n; cin >> a >> b >> n; if (n % 3 == 0) { cout << a << "\n"; } else if (n % 3 == 1) { cout << b << "\n"; } else cout << (a ^ b) << "\n"; } int main() { int tc; cin >> tc; while (tc--) { test_case(); } }
#include <bits/stdc++.h> using namespace std; template <class T> T max(T a, T b, T c) { return max(a, max(b, c)); } void solve() { long long a, b, N; cin >> a >> b >> N; switch (N % 3) { case 0: cout << a << "\n"; break; case 1: cout << b << "\n"; break; case 2: long long curr = a ^ b; cout << curr << "\n"; break; } } int32_t main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); long long T; cin >> T; while (T--) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; long long int gn(long long int n, long long int a, long long int b) { if (n == 0) return a; if (n == 1) return b; if (n == 2) return (a ^ b); return gn(n % 3, a, b); } int main() { int q; cin >> q; for (int i = 0; i < q; ++i) { long long int a, b, n; cin >> a >> b >> n; cout << gn(n, a, b) << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { ios_base ::sync_with_stdio(false); cin.tie(nullptr); int TC; cin >> TC; while (TC--) { long long a, b, n; cin >> a >> b >> n; long long arr[3]{a, b, a ^ b}; cout << arr[n % 3] << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int t; cin >> t; while (t--) { int a, b, n; cin >> a >> b >> n; int c = a ^ b; int u = n % 3; if (u == 0) cout << a << "\n"; else if (u == 1) cout << b << "\n"; else cout << c << "\n"; } }
#include <bits/stdc++.h> using namespace std; const long long INF = (long long)1e9; const long long inf = (long long)1e18; const long double eps = (long double)1e-6; const long long mod = (long long)1e9 + 7; const long long MAXN = 1001; const long long MAXLOG = 19; const long long maxlen = (long long)1e5; const long long asci = (long long)256; const long long block = 707; template <class T> istream &operator>>(istream &in, vector<T> &arr) { for (T &cnt : arr) { in >> cnt; } return in; }; void solve() { long long n, a, b; cin >> a >> b >> n; if (n % 3 == 0) cout << a; if (n % 3 == 1) cout << b; if (n % 3 == 2) cout << (a ^ b); cout << "\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t; cin >> t; while (t--) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; scanf("%d", &t); while (t--) { int a, b, n; scanf("%d%d%d", &a, &b, &n); int mod = n % 3; if (mod == 0) printf("%d\n", a); else if (mod == 1) printf("%d\n", b); else printf("%d\n", (a ^ b)); } return 0; }
#include <bits/stdc++.h> using namespace std; int t; int n, a, b; int main() { cin.sync_with_stdio(false); cin >> t; while (t--) { cin >> a >> b >> n; n = n % 3; if (n == 0) { cout << a << endl; } else if (n == 1) cout << b << endl; else cout << (a ^ b) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long int a, b, c, n; cin >> a >> b >> n; c = a ^ b; n = n % 3; if (n == 0) cout << a << endl; else if (n == 1) cout << b << endl; else cout << c << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int x; cin >> x; while (x--) { long long int a, b, n; cin >> a >> b >> n; if (n % 3 == 0) { cout << a << endl; } else if (n % 3 == 1) { cout << b << endl; } else { a = a ^ b; cout << a << endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, a, b; cin >> a >> b >> n; if (n % 3 == 0) cout << a << endl; if (n % 3 == 1) cout << b << endl; if (n % 3 == 2) cout << (a ^ b) << endl; } }
#include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const long long int LINF = 0x3f3f3f3f3f3f3f3fll; mt19937 rng((int)chrono::steady_clock::now().time_since_epoch().count()); const int MAX = (int)1e5 + 10; int main() { ios::sync_with_stdio(false); ; int t; cin >> t; long long int a, b; while (t--) { int n; cin >> a >> b >> n; n = n % 3; if (n == 0) { cout << a << '\n'; } else if (n == 1) { cout << b << '\n'; } else { cout << (a ^ b) << '\n'; } } return 0; }
#include <bits/stdc++.h> using namespace std; template <class C> void setmin(C &a, C b) { if (a > b) a = b; } template <class C> void setmax(C &a, C b) { if (a < b) a = b; } template <class C> void printv(vector<C> vec, string end = " ") { for (auto const &iter : vec) cout << iter << end; if (end != "\n") cout << endl; } template <class C> void printv(set<C> setc, string end = " ") { for (auto const &iter : setc) cout << iter << end; if (end != "\n") cout << endl; } template <class C> void print(C A[], long long n, string end = " ") { for (long long iter = 0; iter < n; ++iter) cout << A[iter] << end; if (end != "\n") cout << endl; } class Solution { public: void SolutionFunc() { long long a, b, n; cin >> a >> b >> n; if (n % 3 == 0) cout << a << endl; else if (n % 3 == 1) cout << b << endl; else cout << (a ^ b) << endl; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; Solution ob; long long t = 1; cin >> t; for (long long t1 = 0; t1 < t; ++t1) { ob.SolutionFunc(); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, t, n, temp, temp1, c = 0; scanf("%lld", &t); for (long long j = 0; j < t; j++) { scanf("%lld", &a), scanf("%lld", &b), scanf("%lld", &n); long long ar[4]; ar[0] = a, ar[1] = b, ar[2] = (a ^ b); long long ans; ans = ar[n % 3]; printf("%lld", ans), printf("\n"); } }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b, n, x; cin >> a >> b >> n; x = a ^ b; if (n % 3 == 0) cout << a << endl; if (n % 3 == 1) cout << b << endl; if (n % 3 == 2) cout << x << endl; } }
#include <bits/stdc++.h> using namespace std; const int maxn = 1 << 21; const int N = int(1e5); const long long mod = int(1e9) + 7; const long long inf = 1e18; const double PI = 3.1415926536; inline int Set(int n, int pos) { return n = n | 1 << pos; } inline bool check(int n, int pos) { return n & 1 << pos; } inline int Reset(int n, int pos) { return n = n & ~(1 << pos); } inline int lastbit(int n) { return n & (-n); } inline long long mult_mod(long long a, long long b) { a = a % mod; b = b % mod; long long c = (a * b) % mod; return c; } inline long long add_mod(long long a, long long b) { a = (a + mod) % mod; b = (b + mod) % mod; long long c = (a + b) % mod; return c; } inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } inline long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); } inline long long power(long long a, long long b) { long long ans = 1; a = a % mod; while (b) { if (b & 1) ans = (ans * a) % mod; b >>= 1; a = (a * a) % mod; } return ans; } inline long long invmod(long long a) { long long ans = power(a, mod - 2); return ans; } inline unsigned long long mulmod(unsigned long long a, unsigned long long b, unsigned long long c) { unsigned long long x = 0, y = a % c; while (b > 0) { if (b % 2) x = (x + y) % c; y = (y * 2) % c; b >>= 1; } return x % c; } inline unsigned long long Largepower(unsigned long long a, unsigned long long b, unsigned long long c) { unsigned long long x = 1, y = a % c; while (b > 0) { if (b & 1) x = mulmod(x, y, c); y = mulmod(y, y, c); b >>= 1; } return x; } inline long long Egcd(long long a, long long b, long long *x, long long *y) { if (a == 0) { *x = 0, *y = 1; return b; } long long x1, y1; long long gcd = Egcd(b % a, a, &x1, &y1); *x = y1 - (b / a) * x1; *y = x1; return gcd; } inline int bs(int arr[], int l, int r, int item) { if (l == r) { if (arr[l] == item) return r; else return -1; } if (item <= arr[(l + r) / 2]) return bs(arr, l, (l + r) / 2, item); else return bs(arr, (l + r) / 2 + 1, r, item); } inline long long nCrMod(long long n, long long r) { if (r > n / 2) r = n - r; long long ans = 1; for (long long i = 1; i <= r; i++) { ans = (ans % mod * (n - r + i + mod) % mod) % mod; ans = (ans % mod * invmod(i) % mod) % mod; } return ans % mod; } inline long long nCr(long long n, long long r) { if (r > n / 2) r = n - r; long long ans = 1; for (long long i = 1; i <= r; i++) { ans = (ans * (n - r + i)); ans /= i; } return ans; } inline void fastin(int &x) { x = 0; char c = getchar(); while (c < '0' || c > '9') c = getchar(); while (c >= '0' && c <= '9') { x = (x << 3) + (x << 1) + c - '0'; c = getchar(); } return; } int leap[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int nleap[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t--) { int a, b, n; cin >> a >> b >> n; if (n % 3 == 0) { cout << a << endl; } else if (n % 3 == 1) { cout << b << endl; } else { cout << (a ^ b) << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a, b, c; vector<int> ans; for (int i = 0; i < n; ++i) { cin >> a >> b >> c; ans.clear(); ans.push_back(a); ans.push_back(b); int x = 0, y = 1, t = 1; if (a == 0) { if (c % 3 == 0) { cout << a << endl; } else { cout << b << endl; } } else if (b == 0) { if (c % 3 == 1) { cout << b << endl; } else { cout << a << endl; } } else { while (t == 1) { int g = ans[x] ^ ans[y]; if (g == ans[0]) { t = 0; } else { ans.push_back(g); } ++x; ++y; } cout << ans[c % (int)(ans.size())] << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int T, a, b, n, k, ans; cin >> T; for (int i = 0; i < T; i++) { cin >> a >> b >> n; k = n % 3; if (k == 0) ans = a; else if (k == 1) ans = b; else ans = a ^ b; cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; long long x[2000]; int main() { ios_base::sync_with_stdio(0), cin.tie(0); int t; cin >> t; for (int i = 1; i <= t; i++) { long long k = 3, a, b, n; cin >> a >> b >> n; x[0] = a; x[1] = b; x[2] = (a ^ b); int m = n % k; cout << x[m] << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int tests; cin >> tests; while (tests--) { long long a, b, n; cin >> a >> b >> n; n = n % 3; if (n == 0) { cout << a << endl; } else if (n == 1) { cout << b << endl; } else { cout << (a ^ b) << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; while (t--) { int a, b, n; cin >> a >> b >> n; if (n % 3 == 0) { cout << a << endl; } else if (n % 3 == 1) { cout << b << endl; } else { cout << (a ^ b) << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long a, b, n; cin >> a >> b >> n; if (n % 3 == 0) cout << a; else if (n % 3 == 1) cout << b; else cout << (a ^ b); cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, a, b, t, ans, i; cin >> t; while (t--) { cin >> a >> b >> n; i = a ^ b; if (n % 3 == 0) { cout << a << endl; } else if (n % 3 == 1) cout << b << endl; else cout << i << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int t, a, b, n; cin >> t; while (t--) { cin >> a >> b >> n; if (n % 3 == 0) { cout << a; } else if (n % 3 == 1) { cout << b; } else cout << (a ^ b); cout << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; while (t--) { long long a, b, n; cin >> a >> b >> n; if (n == 0) cout << a << endl; else if (n == 1) cout << b << endl; else { long long num = (a ^ b); long long rem = n % 3; if (rem == 0) cout << a << endl; else if (rem == 1) cout << b << endl; else if (rem == 2) cout << num << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long t, a, b, n; cin >> t; while (t--) { cin >> a >> b >> n; if (n % 3 == 0) cout << a << endl; else if (n % 3 == 1) cout << b << endl; else cout << (a ^ b) << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long int a, b, n, val; cin >> a >> b >> n; val = a ^ b; if (n % 3 == 0) { cout << a << endl; } else if (n % 3 == 1) { cout << b << endl; } else { cout << val << endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long a, b, n; cin >> a >> b >> n; n %= 3; if (n == 0) cout << a << "\n"; else if (n == 1) cout << b << "\n"; else cout << (a ^ b) << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int xorinacci(int a, int b, int n) { if (n == 0) return a; if (n == 1) return b; if (a == 0 && b == 0) return 0; if (n % 3 == 0) return a; if (n % 3 == 1) return b; if (n % 3 == 2) { int c = a ^ b; return c; } return 0; } int main() { ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; while (t--) { int a, b, n; cin >> a >> b >> n; cout << xorinacci(a, b, n) << "\n"; } }
#include <bits/stdc++.h> using namespace std; int n, a, b; void solve(int tc) { cin >> a >> b >> n; int three = a ^ b; if (n % 3 == 0) { cout << a << "\n"; } else if (n % 3 == 1) { cout << b << "\n"; } else { cout << three << "\n"; } } int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); time_t startt = clock(); int tt; cin >> tt; for (int tc = 1; tc <= tt; tc++) { solve(tc); } return 0; }
#include <bits/stdc++.h> using namespace std; const int MOD = (int)1e9 + 7; const int FFTMOD = 119 << 23 | 1; const int INF = (int)1e9 + 23111992; const long long LINF = (long long)1e18 + 23111992; const long double PI = acos((long double)-1); const long double EPS = 1e-9; inline long long gcd(long long a, long long b) { long long r; while (b) { r = a % b; a = b; b = r; } return a; } inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } inline long long fpow(long long n, long long k, int p = MOD) { long long r = 1; for (; k; k >>= 1) { if (k & 1) r = r * n % p; n = n * n % p; } return r; } template <class T> inline int chkmin(T& a, const T& val) { return val < a ? a = val, 1 : 0; } template <class T> inline int chkmax(T& a, const T& val) { return a < val ? a = val, 1 : 0; } inline unsigned long long isqrt(unsigned long long k) { unsigned long long r = sqrt(k) + 1; while (r * r > k) r--; return r; } inline long long icbrt(long long k) { long long r = cbrt(k) + 1; while (r * r * r > k) r--; return r; } inline void addmod(int& a, int val, int p = MOD) { if ((a = (a + val)) >= p) a -= p; } inline void submod(int& a, int val, int p = MOD) { if ((a = (a - val)) < 0) a += p; } inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; } inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); } inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; } inline int sign(long double x, long double y) { return sign(x - y); } mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count()); inline int mrand() { return abs((int)mt()); } void solve() { int test; cin >> test; while (test--) { int a, b, n; cin >> a >> b >> n; if (n < 1000) { for (int i = (0); i < (n); ++i) { a = a ^ b; swap(a, b); } cout << a << "\n"; } else { for (int i = (0); i < (1000); ++i) { a = a ^ b; swap(a, b); } n -= 1000; n %= 1 * 2 * 3 * 4 * 5; for (int i = (0); i < (n); ++i) { a = a ^ b; swap(a, b); } cout << a << "\n"; } } } int main(int argc, char* argv[]) { ios_base::sync_with_stdio(0), cin.tie(0); if (argc > 1) { assert(freopen(argv[1], "r", stdin)); } if (argc > 2) { assert(freopen(argv[2], "wb", stdout)); } solve(); cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n"; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int i, e = 0, n, c = 0, d = 0, a, b; cin >> a >> b >> n; e = n % 3; if (e == 0) { cout << a << endl; } else if (e == 1) { cout << b << endl; } else { c = a ^ b; cout << c << endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b, n; cin >> a >> b >> n; switch (n % 3) { case 0: cout << a << endl; break; case 1: cout << b << endl; break; default: cout << (a ^ b) << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long t; cin >> t; for (int i = 0; i < t; i++) { long n, a, b; cin >> a >> b >> n; switch (n % 3) { case 0: cout << a; break; case 1: cout << b; break; case 2: long c = a ^ b; cout << c; break; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const long long BINF = 9e18, LINF = 2e9, mod = 1e9 + 7, P = 179, Q = 1791791791; void solve() { long long a, b, n; cin >> a >> b >> n; if (n % 3 == 0) cout << a << "\n"; else if (n % 3 == 1) cout << b << "\n"; else cout << (a ^ b) << "\n"; return; } signed main() { ios_base::sync_with_stdio(false); cout.precision(40); long long t; cin >> t; for (long long i = 0; i < t; ++i) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; signed main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0); long long test = 1; cin >> test; while (test--) { long long a[3], n; cin >> a[0] >> a[1] >> n; a[2] = a[0] ^ a[1]; long long x = n % 3; cout << a[x] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); int t; cin >> t; while (t--) { long long a, b, n; cin >> a >> b >> n; if (n % 3 == 0) cout << a << endl; if (n % 3 == 1) cout << b << endl; if (n % 3 == 2) cout << (a ^ b) << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int t; int a, b, n; int main() { cin >> t; while (t--) { cin >> a >> b >> n; if (n % 3 == 0) cout << a; else if (n % 3 == 1) cout << b; else cout << (a ^ b); cout << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; long long int a, b, n; while (t--) { cin >> a >> b >> n; n %= 3; if (n == 0) cout << a << endl; else if (n == 1) cout << b << endl; else cout << (a ^ b) << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b, n, c, mod; cin >> a >> b >> n; mod = n % 3; c = a ^ b; if (mod == 0) cout << a << '\n'; else if (mod == 1) cout << b << '\n'; else cout << c << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; void solve() { long long i, j = 0, r = 200, p, q, k = 1, ans = 0, d, y = 0, x, n, h, flag = 0, m = 0, id, c, h1, h2, a1, b1, w, a, b; cin >> p >> q >> n; if (n % 3 == 0) cout << p << endl; else if (n % 3 == 1) cout << q << endl; else cout << (p ^ q) << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t = 1; cin >> t; while (t--) solve(); }
#include <bits/stdc++.h> using namespace std; long long int i, j, count, k, t, l, n, a, b, sum1, sum2, max1, max2; string s1, s2; int main() { cin >> t; while (t--) { cin >> a >> b >> n; n = n % 3; if (n == 0) { cout << a << endl; } else if (n == 1) { cout << b << endl; } else { cout << (a ^ b) << endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; for (int test = 0; test < t; test++) { int a, b, n; cin >> a >> b >> n; if (n % 3 == 0) { cout << a; } else if (n % 3 == 1) { cout << b; } else cout << (a ^ b); cout << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int F(int a, int b, int n) { int f2, f1 = b, f0 = a; for (int i = 1; i < n; i++) { f2 = f1 ^ f0; f0 = f1; f1 = f2; } return f2; } int main() { int T; cin >> T; int a, b, n; for (int i = 0; i < T; i++) { cin >> a >> b >> n; n %= 3; if (n == 0) cout << a << '\n'; else if (n == 1) cout << b << '\n'; else cout << F(a, b, n) << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; int T, n, a, b; int main() { cin >> T; while (T--) { int res = 0; cin >> a >> b >> n; if (n == 0) { cout << a << endl; continue; } else if (n == 1) { cout << b << endl; continue; } for (int i = 0; i < 31; ++i) { int bit = 1 << i; int ai = a & bit, bi = b & bit; if (!ai && !bi) continue; else if (ai && bi) { if (n % 3 != 2) res += bit; } else if (ai) { if (n % 3 != 1) res += bit; } else if (bi) { if (n % 3 != 0) res += bit; } } cout << res << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long t, n, a, b; cin >> t; while (t--) { cin >> a >> b >> n; if (n % 3 == 0) cout << a << "\n"; if (n % 3 == 1) cout << b << "\n"; if (n % 3 == 2) cout << (a ^ b) << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; long long int a, b, n; cin >> t; while (t--) { cin >> a >> b >> n; long long int c = a ^ b; long long int x = n % 3; long long int ans = x == 0 ? a : x == 1 ? b : c; cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int n, a, b, f[3]; int main() { int t; scanf("%d", &t); while (t--) { scanf("%d%d%d", &a, &b, &n); n %= 3; f[0] = a; f[1] = b; f[2] = a ^ b; printf("%d\n", f[n]); } }
#include <bits/stdc++.h> using namespace std; int t; int a, b, c, n; int main() { cin >> t; while (t--) { cin >> a >> b >> n; c = a ^ b; switch (n % 3) { case 0: cout << a << endl; break; case 1: cout << b << endl; break; case 2: cout << c << endl; break; } } return 0; }
#include <bits/stdc++.h> int main(int argc, char **argv) { int n, a, b, m, c; std::cin >> n; for (int i = 0; i < n; i++) { std::cin >> a >> b >> m; c = a ^ b; if (m % 3 == 0) std::cout << a << "\n"; else if (m % 3 == 1) std::cout << b << "\n"; else std::cout << c << "\n"; } getchar(); return (0); }
#include <bits/stdc++.h> using namespace std; int main() { long long a, b, c, d, i, j, k; long long t; cin >> t; while (t--) { cin >> a >> b >> c; if (c % 3 == 0) { cout << a << endl; } else if (c % 3 == 1) { cout << b << endl; } else { cout << (a ^ b) << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int f[1007]; int main() { long long a, b, n, t, s; cin >> t; for (int i = 0; i < t; i++) { cin >> a >> b >> n; if (n % 3 == 0) { cout << a << endl; } else if (n % 3 == 1) { cout << b << endl; } else { s = a ^ b; cout << s << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); srand(time(NULL)); long long int t; cin >> t; while (t--) { long long int a, b, n; cin >> a >> b >> n; if (n % 3 == 0) cout << a << "\n"; else if (n % 3 == 1) cout << b << "\n"; else cout << (a ^ b) << "\n"; } }
#include <bits/stdc++.h> using namespace std; int main() { long long t, a, b, n, z; cin >> t; while (t--) { cin >> a >> b >> n; if (n % 3 == 0) { cout << a << endl; } else if (n % 3 == 1) { cout << b << endl; } else { z = a ^ b; cout << z << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); ; long long int a, b, c, t, i, e; vector<long long int> d(10000); cin >> t; while (t--) { e = 0; cin >> a >> b >> c; d[1] = b; if (c % 3 == 0) e = a; else if (c % 3 == 1) e = b; else e = (a ^ b); cout << e << endl; } }
#include <bits/stdc++.h> using namespace std; const double oo = 1e7; const double EPS = (1e-9); int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; } struct edge { long long from, to, w; edge(long long u, long long v, long long w) : from(u), to(v), w(w) {} bool operator<(const edge &e) const { return w > e.w; } }; int main() { int t; long long a, b, n; cin >> t; for (int i = 0; i < t; i++) { cin >> a >> b >> n; n %= 3; if (n == 0) cout << a; else if (n == 1) cout << b; else cout << (a ^ b); cout << endl; } }
#include <bits/stdc++.h> using namespace std; int t; long long a, b, n; int main() { scanf("%d", &t); while (t--) { scanf("%I64d %I64d %I64d", &a, &b, &n); if (n % 3 == 1) printf("%I64d\n", b); else if (n % 3 == 2) printf("%I64d\n", a ^ b); else printf("%I64d\n", a); } return 0; }
#include <bits/stdc++.h> #pragma GCC optimize("O3", "unroll-loops") #pragma GCC target("avx2") using namespace std; template <class T, class U> inline void checkmin(T& x, U y) { if (y < x) x = y; } template <class T, class U> inline void checkmax(T& x, U y) { if (y > x) x = y; } template <class T, class U> inline bool ifmax(T& x, U y) { if (y > x) return x = y, true; return false; } template <class T, class U> inline bool ifmin(T& x, U y) { if (y < x) return x = y, true; return false; } template <class T> inline void sort(T& a) { sort(a.begin(), a.end()); } template <class T> inline void rsort(T& a) { sort(a.rbegin(), a.rend()); } template <class T> inline void reverse(T& a) { reverse(a.begin(), a.end()); } template <class T, class U> inline istream& operator>>(istream& str, pair<T, U>& p) { return str >> p.first >> p.second; } template <class T> inline istream& operator>>(istream& str, vector<T>& a) { for (auto& i : a) str >> i; return str; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << fixed << setprecision(12); srand(94385); long long t, a, b, n; cin >> t; while (t--) { cin >> a >> b >> n; if (n % 3 == 0) cout << a; else if (n % 3 == 1) cout << b; else cout << (a ^ b); cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long mpow(long long x, long long y, long long m) { long long t = (y ? mpow(x, y / 2, m) : -1); return (t == -1 ? 1 % m : ((t * t % m) * ((y % 2) ? x : 1)) % m); } long long n1, n2, p1, p2, m, n; long long trueDiv(long long a, long long b) { long double tmp = (long double)a / (long double)b; long long tmpl = a / b; if (tmp != tmpl) return tmpl + 1; return tmpl; } void err(string s) { cout << s; exit(0); } long long norm(long long x) { return x < 0 ? 0 : x; } bool comp(pair<long long, long long> a, pair<long long, long long> b) { return a.second > b.second; } long long d[5][5], ans[5]; vector<long long> kick(vector<long long> x, long long val) { vector<long long> ans; for (auto y : x) { if (y != val) ans.push_back(y); } return ans; } long long calc(vector<long long> v) { long long ans = 0; for (long long i = 0; i < (v.size() - 1); i++) { ans += d[v[i] - 1][v[i + 1] - 1]; } return ans; } vector<vector<long long>> ways = { {1, 3, 2, 4, 5}, {1, 3, 4, 2, 5}, {1, 2, 3, 4, 5}, {1, 4, 3, 2, 5}}; vector<pair<long double, long double>> get(long double x, long double y) { vector<pair<long double, long double>> ans = {{x, y + 1.0}, {x + 1.0, y}}; return ans; } long double in(pair<long double, long double> x) { return (long double)m * x.first - (long double)n * x.second; } long long arr[4][4]; void rotate() { long long tmp[4][4]; for (long long i = 0; i < (4); i++) { for (long long j = 0; j < (4); j++) { tmp[i][j] = arr[i][j]; } } for (long long j = 0; j < (4); j++) { for (long long i = (4) - 1; i >= 0; i--) { arr[j][3 - i] = tmp[i][j]; } } } void print() { for (long long i = 0; i < (4); i++) { for (long long j = 0; j < (4); j++) { cout << arr[i][j] << " "; } cout << "\n"; } } vector<long long> v; bool f(long long a, long long b) { return a > b; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t; cin >> t; for (long long i = 0; i < (t); i++) { long long a, b; cin >> a >> b >> n; vector<long long> v = {a, b, (a ^ b)}; n %= 3; cout << v[n] << "\n"; } }
#include <bits/stdc++.h> using namespace std; const long long MAX = 1010; void solve() { long long a, b, n; cin >> a >> b >> n; if (n % 3 == 0) { cout << a << endl; } else if (n % 3 == 1) { cout << b << endl; } else { cout << (a ^ b) << endl; } } int main() { long long q; cin >> q; for (long long i = 0; i < q; i++) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; void solve() { long long a, b, c; cin >> a >> b >> c; long long find = a ^ b; long long ret = c % 3; if (ret == 0) { cout << a << endl; } else if (ret == 1) { cout << b << endl; } else { cout << find << endl; } } int main() { long long T = 1; cin >> T; while (T--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; long long a[4], n, myd; signed main() { cin >> n; while (n--) { cin >> a[0] >> a[1] >> myd; myd %= 3; a[2] = a[0] ^ a[1]; cout << a[myd] << endl; } }
#include <bits/stdc++.h> using namespace std; int n, a, b, x; int main() { scanf("%d", &n); while (n--) { scanf("%d%d%d", &a, &b, &x); if (x % 3 == 0) printf("%d\n", a); if (x % 3 == 1) printf("%d\n", b); if (x % 3 == 2) printf("%d\n", a ^ b); } }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int a, b, n; cin >> a >> b >> n; if (n % 3 == 0) { cout << a << endl; } else if (n % 3 == 1) { cout << b << endl; } else { cout << (a ^ b) << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int a, b, c; cin >> a >> b >> c; vector<int> v{a, b, a ^ b}; cout << v[c % 3] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long t, a, b, n, x, i; cin >> t; for (i = 1; i <= t; i++) { cin >> a >> b >> n; if (n == 0 || n % 3 == 0) { cout << a << endl; continue; } if (n == 1 || n % 3 == 1) { cout << b << endl; continue; } x = a ^ b; { cout << x << endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int t; cin >> t; while (t--) { long long a, b, n; cin >> a >> b >> n; if (n == 0) cout << a << "\n"; else if (n == 1) cout << b << "\n"; else if (n % 3 == 0) cout << a << "\n"; else if (n % 3 == 1) cout << b << "\n"; else cout << (a ^ b) << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; template <class T> void read(T &u) { u = 0; char c = getchar(); int flag = 0; while (c < '0' || c > '9') flag |= (c == '-'), c = getchar(); while (c >= '0' && c <= '9') u = (u << 3) + (u << 1) + (c ^ 48), c = getchar(); if (flag) u = -u; } bool checkmin(int &a, int b) { return (b < a ? a = b, 1 : 0); } bool checkmax(int &a, int b) { return (b > a ? a = b, 1 : 0); } int T; int a, b, n; void init() { read(a); read(b); read(n); } void solve() { if (n % 3 == 0) printf("%d\n", a); else if (n % 3 == 1) printf("%d\n", b); else printf("%d\n", (a ^ b)); } int main() { read(T); while (T--) { init(); solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; int a, b, n; while (T--) { cin >> a >> b >> n; n %= 3; if (n == 0) cout << a; else if (n == 1) cout << b; else cout << (a ^ b); puts(""); } return 0; }
#include <bits/stdc++.h> using namespace std; int Solve(int a, int b, int n) { int ans = 0; int q10 = (n - 1) % 3; if (q10) { q10 = 1; } int q01 = n % 3; if (q01) { q01 = 1; } int q11 = (n + 1) % 3; if (q11) { q11 = 1; } int c = a xor b; while (a || b) { if (a & 1 && b & 1) { ans += q11; } else if (a & 1) { ans += q10; } else if (b & 1) { ans += q01; } a = a >> 1; b = b >> 1; q10 = q10 << 1; q01 = q01 << 1; q11 = q11 << 1; } return ans; } int main() { int T; cin >> T; for (int t = 0; t < T; ++t) { int a, b, n; cin >> a >> b >> n; if (n == 0) { cout << a << endl; } else if (n == 1) { cout << b << endl; } else { cout << Solve(a, b, n) << endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { int T; cin >> T; while (T--) { int a, b, n; cin >> a >> b >> n; int rem = n % 3; if (rem == 0) { cout << a << '\n'; } else if (rem == 1) { cout << b << '\n'; } else { cout << (a ^ b) << '\n'; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int test, a[3], n; cin >> test; while (test--) { cin >> a[0] >> a[1] >> n; a[2] = a[0] ^ a[1]; cout << a[n % 3] << '\n'; } }
#include <bits/stdc++.h> using namespace std; long long Pow(long long x, long long y, long long m) { if (y == 0) return 1; long long p = Pow(x, y / 2, m) % m; p = (p * p) % m; return (y % 2 == 0) ? p : (x * p) % m; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long i; long long t; cin >> t; while (t--) { long long a, b, n; cin >> a >> b >> n; if (n % 3 == 0) cout << a << "\n"; else if (n % 3 == 1) cout << b << "\n"; else cout << (a ^ b) << "\n"; } }