text stringlengths 49 983k |
|---|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
;
int t;
cin >> t;
while (t--) {
int a, b, n;
cin >> a >> b >> n;
vector<int> v(3);
v[0] = a;
v[1] = b;
v[2] = a ^ b;
cout << v[n % 3] << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
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';
}
}
|
#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);
if (n > 1) {
int d = (n - 1) % 3;
if (d == 1)
printf("%d\n", (a ^ b));
else if (d == 2)
printf("%d\n", a);
else
printf("%d\n", b);
} else if (n == 1)
printf("%d\n", b);
else
printf("%d\n", a);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
bool isvowel(char c) {
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' ||
c == 'E' || c == 'I' || c == 'O' || c == 'U')
return true;
return false;
}
bool prime[1000001];
int spf[1000001];
vector<int> primes;
void sieve() {
memset(prime, true, sizeof(prime));
for (int p = 2; p * p <= 1000000; p++) {
if (prime[p] == true) {
for (int i = p * p; i <= 1000000; i += p) {
prime[i] = false;
spf[i] = p;
}
}
}
for (int p = 2; p <= 1000000; p++)
if (prime[p]) primes.push_back(p);
}
long long int gcd(long long int a, long long int b) {
if (b == 0) return a;
return gcd(b, a % b);
}
long long int fast_exp(long long int x, long long int n) {
long long int ans = 1;
while (n) {
if (n & 1) ans *= x;
n = n >> 1;
x = x * x;
}
return ans;
}
long long int mod_exp(long long int x, long long int y, long long int p) {
long long int res = 1;
x = x % p;
while (y > 0) {
if (y & 1) res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
int main() {
int t;
cin >> t;
while (t--) {
long long int a, b, n;
cin >> a >> b >> n;
long long int c = a ^ b;
if (n % 3 == 0) cout << a;
if (n % 3 == 1) cout << b;
if (n % 3 == 2) cout << c;
cout << '\n';
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
long long a, b, c, n;
long long t;
cin >> t;
while (t--) {
cin >> a >> b >> n;
c = a ^ b;
long long mod = n % 3;
if (mod == 0)
cout << a << endl;
else if (mod == 1) {
cout << b << endl;
} else
cout << c << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
constexpr int maxn = 100;
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;
if (n % 3 == 1) cout << b << endl;
if (n % 3 == 2) cout << (a ^ b) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
long long a, b, n;
void Input() {
cin >> a >> b >> n;
n++;
}
void Solve() {
long long x = a ^ b;
if (n % 3 == 1)
cout << a << "\n";
else if (n % 3 == 2)
cout << b << "\n";
else
cout << x << "\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long T = 1;
cin >> T;
while (T--) {
Input();
Solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int a, b;
int n;
cin >> a >> b;
cin >> n;
if (n % 3 == 0)
cout << a << endl;
else if (n % 3 == 1)
cout << b << endl;
else
cout << int(a ^ b) << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, a, b;
cin >> a >> b >> n;
int xorvalue = a ^ b;
n = n % 3;
if (n == 0)
cout << a << endl;
else if (n == 1)
cout << b << endl;
else
cout << xorvalue << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(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 << 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--) {
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;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long int line, a, b, n, i, j;
cin >> line;
while (line--) {
cin >> a >> b >> n;
long long int c = a ^ b;
if (n % 3 == 0) {
cout << a << endl;
} else if (n % 3 == 1) {
cout << b << endl;
} else {
cout << c << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int f[3];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tt;
cin >> tt;
while (tt--) {
int n;
cin >> f[0] >> f[1] >> n;
f[2] = f[0] ^ f[1];
cout << f[n % 3] << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000007;
const long long inf = 1e6 + 21;
long long powmod(long long a, long long b) {
long long res = 1;
a %= mod;
assert(b >= 0);
for (; b; b >>= 1) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
}
return res;
}
template <typename N>
N gcd(N a, N b) {
return b ? gcd(b, a % b) : a;
}
void precision(long long pr) {
cout.precision(pr);
cout << fixed;
}
const long long N = 121;
int main() {
long long t, a, b, n, i, j, k;
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';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int x, y, z, arr[3], t, idx;
cin >> t;
while (t--) {
cin >> x >> y >> idx;
arr[0] = x;
arr[1] = y;
arr[2] = x ^ y;
cout << arr[idx % 3] << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
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;
const long int N = 2e6 + 200;
long int arr[N], ans[N];
set<pair<long int, long int>> s1, s2;
map<long int, long int> mp;
pair<long int, long int> p;
int main() {
long int t;
cin >> t;
while (t--) {
long int n, a, b;
cin >> a >> b >> n;
if (n % 3 == 0)
cout << a;
else if (n % 3 == 1)
cout << b;
else
cout << (long int)(a ^ b);
cout << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, i, j, m;
long long t;
cin >> t;
while (t--) {
long long a, b, c, n, bo;
cin >> a >> b >> n;
c = a ^ b;
bo = n % 3;
if (bo == 0)
cout << a << endl;
else if (bo == 1)
cout << b << endl;
else
cout << c << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
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() {
int t, i = 1;
cin >> t;
while (t--) {
solve();
++i;
}
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 f[3];
f[0] = a, f[1] = b, f[2] = a ^ b;
cout << f[n % 3] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n, a, b;
cin >> t;
while (t--) {
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;
long long int gcd(long long int a, long long int b) {
return b ? gcd(b, a % b) : a;
}
long long int power(long long int a, long long int b) {
long long int ans = 1;
while (b) {
if (b & 1) {
ans = (ans * a) % 1000000007;
}
a = (a * a) % 1000000007;
b >>= 1;
}
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(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";
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
int ans;
int x, a, b;
cin >> a >> b >> x;
if (x % 3 == 0)
ans = a;
else if (x % 3 == 1)
ans = b;
else
ans = a ^ b;
cout << ans << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long t, n, a, b;
cin >> t;
while (t--) {
cin >> a >> b >> n;
if (n == 0) {
cout << a << endl;
} else if (n == 1) {
cout << b << endl;
} else {
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 n;
cin >> n;
for (long long i = 0; i < n; i++) {
int a, b, n, ab;
cin >> a >> b >> n;
ab = a ^ b;
if ((n) % 3 == 1)
cout << b << endl;
else if ((n) % 3 == 0)
cout << a << endl;
else
cout << ab << endl;
}
}
|
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
int main() {
srand(1373737);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin >> t;
while (t--) {
long long a, b, n;
cin >> a >> b >> n;
if (n % 3ll == 0ll) cout << a << '\n';
if (n % 3ll == 1ll) cout << b << '\n';
if (n % 3ll == 2ll) cout << (a ^ b) << '\n';
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int ROW[] = {+1, -1, +0, +0};
int COL[] = {+0, +0, +1, -1};
int X[] = {+0, +0, +1, -1, -1, +1, -1, +1};
int Y[] = {-1, +1, +0, +0, +1, +1, -1, -1};
int KX[] = {-2, -2, -1, -1, 1, 1, 2, 2};
int KY[] = {-1, 1, -2, 2, -2, 2, -1, 1};
void fastscan(int& number) {
bool negative = false;
int c;
number = 0;
c = getchar();
if (c == '-') {
negative = true;
c = getchar();
}
for (; (c > 47 && c < 58); c = getchar()) number = number * 10 + c - 48;
if (negative) number *= -1;
}
long long GCD(long long a, long long b) { return b == 0 ? a : GCD(b, a % b); }
int LCM(int a, int b) { return a * (b / GCD(a, b)); }
bool CMP(int a, int b) { return a > b; }
int main() {
int t, ca = 1;
cin >> t;
while (t--) {
int a[3], n;
cin >> a[0] >> a[1] >> n;
a[2] = a[0] ^ a[1];
cout << a[n % 3] << endl;
}
END:
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
long long t, a, b, n;
cin >> t;
while (t--) {
cin >> a >> b >> n;
n %= 3;
if (!n)
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 main() {
int t;
cin >> t;
while (t--) {
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
cout << (a ^ b) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
int main() {
int T;
scanf("%d", &T);
while (T--) {
int a, b, n;
scanf("%d%d%d", &a, &b, &n);
int x = n % 3, ans;
if (x == 0)
ans = a;
else if (x == 1)
ans = b;
else
ans = a ^ b;
printf("%d\n", ans);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 13371337;
const int64_t K = 2;
vector<vector<int64_t> > mul(vector<vector<int64_t> > A,
vector<vector<int64_t> > B) {
vector<vector<int64_t> > C(K + 1, vector<int64_t>(K + 1));
for (int i = 1; i <= K; i++)
for (int j = 1; j <= K; j++)
for (int k = 1; k <= K; k++) {
C[i][j] ^= (A[i][k] * B[k][j]);
}
return C;
}
vector<vector<int64_t> > pow(vector<vector<int64_t> > A, int64_t p) {
if (p == 1) return A;
if (p % 2) return mul(A, pow(A, p - 1));
vector<vector<int64_t> > X = pow(A, p / 2);
return mul(X, X);
}
int64_t fib(int64_t N, int64_t resp[]) {
vector<int64_t> F1(K + 1);
F1[1] = resp[0];
F1[2] = resp[1];
vector<vector<int64_t> > T(K + 1, vector<int64_t>(K + 1));
T[1][1] = 1ll, T[1][2] = 1ll;
T[2][1] = 1ll, T[2][2] = 0ll;
if (N == 1) return 1ll;
T = pow(T, N - 1);
int64_t res = 0ll;
for (int i = 1; i <= K; i++) res = res ^ (T[1][i] * F1[i]);
return res;
}
int64_t solve(int64_t c, int64_t a, int64_t b) {
int64_t pd[10];
memset(pd, 0, sizeof pd);
pd[0] = a;
pd[1] = b;
for (int i = 2; i <= c; i++) {
pd[i] = pd[i - 1] ^ pd[i - 2];
}
return pd[c];
}
int main() {
int64_t k, a, b, c, d;
cin >> k;
while (k--) {
cin >> a >> b >> c;
int64_t resp[] = {b, a};
if (c >= 4)
cout << fib(c - 3, resp) << endl;
else
cout << solve(c, a, b) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 1000;
const long long INF64 = 1e18 + 1000;
const int N = 6 * 100 * 1000 + 100;
const int MOD = 1e9 + 9;
long long gcd(long long a, long long b) { return a == 0 ? b : gcd(b % a, a); }
void spr(int x) { cout << setprecision(x) << fixed; }
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int q;
cin >> q;
while (q--) {
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;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
long long a, b, n;
for (int i = 0; i < t; ++i) {
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;
const long long MOD = (1e9) + 7;
const long double EPS = 0.0000001;
long long pows(long long a, long long b) {
if (b == 0) return 1LL;
long long temp = pows(a, b / 2);
temp = (temp * temp) % MOD;
if (b % 2) temp = (temp * a) % MOD;
return temp;
}
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
long long a, b;
cin >> a >> b;
long long n;
cin >> 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>
int main(void) {
int t;
scanf("%d", &t);
while (t--) {
int a, b, n, c;
scanf("%d %d %d", &a, &b, &n);
c = a ^ b;
if (n % 3 == 0) {
printf("%d\n", a);
}
if (n % 3 == 1) {
printf("%d\n", b);
}
if (n % 3 == 2) printf("%d\n", c);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int cases[10];
int main() {
int T;
cin >> T;
while (T--) {
int a, b, n;
cin >> a >> b >> n;
cases[0] = a;
cases[1] = b;
cases[2] = a ^ b;
cout << cases[n % 3] << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, a, b, n;
cin >> t;
while (t--) {
cin >> a >> b >> n;
long long int s = a ^ b;
if ((n) % 3 == 0)
cout << a << "\n";
else if (n % 3 == 1)
cout << b << "\n";
else if (n % 3 == 2)
cout << s << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, a, b, n;
scanf("%d", &t);
while (t--) {
scanf("%d%d%d", &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() {
ios_base::sync_with_stdio(false);
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;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int t;
cin >> t;
while (t--) {
long long int n, a, b;
cin >> a >> b >> n;
n = n % 3;
if (n == 0)
cout << a << "\n";
else if (n == 1)
cout << b << "\n";
else {
long long int x = a ^ b;
cout << x << "\n";
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
while (n--) {
long long a, b, c;
cin >> a >> b >> c;
if (c <= 1) {
if (c == 1) cout << b;
if (c == 0) cout << a;
cout << "\n";
} else {
if (c % 3 == 0)
cout << a;
else if (c % 3 == 1)
cout << b;
else
cout << (a ^ b);
cout << "\n";
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
const int inf = 0x7fffffff;
const int maxn = 1e5 + 7;
int n, m;
int f[maxn];
int main() {
std::ios::sync_with_stdio(false);
int T, a, b;
cin >> T;
while (T--) {
cin >> f[0] >> f[1] >> n;
f[2] = f[1] ^ f[0];
cout << f[n % 3] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long x, y, index;
cin >> x >> y >> index;
long long ans = x ^ y;
if (index % 3 == 0)
cout << x << endl;
else if (index % 3 == 1)
cout << y << endl;
else
cout << ans << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
while (t-- > 0) {
long long a, b, n;
cin >> a >> b >> n;
long long arr[3];
memset(arr, 0, 3);
arr[0] = a;
arr[1] = b;
arr[2] = a ^ b;
if (n % 3 == 0)
cout << a << endl;
else if (n % 3 == 1)
cout << b << endl;
else
cout << (a ^ b) << endl;
}
}
|
#include <bits/stdc++.h>
int a, b, n, T;
int main() {
scanf("%d", &T);
for (int i = 1; i <= T; ++i)
scanf("%d%d%d", &a, &b, &n),
printf("%d\n", n % 3 == 2 ? a ^ b : (n % 3 == 1 ? b : a));
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long square_root(long long n) {
long long l = 1, r = 1e9 + 1;
while (l <= r) {
long long m = (l + r) / 2;
if (m * m <= n && (m + 1) * (m + 1) > n)
return m;
else if (m * m < n) {
l = m + 1;
} else {
r = m - 1;
}
}
return 0;
}
bool isPrime(long long n) {
if (n == 1) return false;
for (long long i = 2; i * i <= n; i++) {
if (n % i == 0) return false;
}
return true;
}
long long cube_root(long long n) {
long long l = 1, r = 1e5 + 1;
while (l <= r) {
long long m = (l + r) / 2;
if (m * m * m <= n && (m + 1) * (m + 1) * (m + 1) > n) {
return m;
} else if (m * m * m < n) {
l = m + 1;
} else {
r = m - 1;
}
}
return 0;
}
struct X {
bool operator()(const long long &p1, const long long &p2) {
return abs(p1) < abs(p2);
}
};
long long a, b, n;
void solve() {
cin >> a >> b >> n;
n %= 3;
if (n == 2) {
cout << (a ^ b) << endl;
return;
}
if (n == 0) {
cout << a << endl;
return;
}
cout << b << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long w = 1;
cin >> w;
while (w--) {
solve();
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long int find(long long a, long long b, long long int n) {
if (n == 0)
return a;
else if (n == 1)
return b;
else if (n == 2)
return a ^ b;
else {
if (n % 3 == 0)
return a;
else if (n % 3 == 1) {
return b;
} else {
return a ^ b;
}
}
}
int main(int argc, char const *argv[]) {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
long long int a, b, n;
cin >> a >> b >> n;
cout << find(a, b, n) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
struct Edge {
int from, to, dist;
Edge(int u, int v, int d) : from(u), to(v), dist(d) {}
};
int T;
int a, b, n, c;
int main() {
ios::sync_with_stdio(0);
cin >> T;
while (T--) {
cin >> a >> b >> n;
c = a ^ b;
n = n % 3;
if (n == 0) cout << a << "\n";
if (n == 1) cout << b << "\n";
if (n == 2) cout << c << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long sum(long long a, long long b, long long mod) {
long long ans = a + b;
if (ans > mod) ans -= mod;
return ans;
}
long long mul(long long a, long long b, long long mod) { return (a * b) % mod; }
long long dif(long long a, long long b, long long mod) {
long long res = a - b;
if (res < 0) res += mod;
return res;
}
long long binpow(long long a, long long b, long long mod) {
if (b == 1) return a;
if (b % 2 == 0) {
long long bb = binpow(a, b / 2, mod);
return mul(bb, bb, mod);
}
if (b % 2 == 1) {
long long bb = binpow(a, b / 2, mod);
bb = mul(bb, bb, mod);
return mul(bb, a, mod);
}
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &V) {
for (int i = 0; i < (int)V.size(); ++i) {
if (i != 0) os << ' ';
os << V[i];
}
return os;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &V) {
for (int i = 0; i < (int)V.size(); ++i) {
is >> V[i];
}
return is;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
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 main() {
long long int t, i, n, a, b, c;
cin >> t;
for (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
cout << (a ^ b) << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t;
cin >> t;
while (t--) {
long long a, b, c;
cin >> a >> b >> c;
c = c % 3;
if (c == 0)
cout << a << "\n";
else if (c == 1)
cout << b << "\n";
else
cout << (a ^ b) << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
long long t, a, b, n;
void solve() {
if (n % 3 == 0)
cout << a << endl;
else if (n % 3 == 1)
cout << b << endl;
else
cout << (a ^ b) << endl;
}
void read() {
cin >> t;
for (int i = 0; i < t; i++) {
cin >> a >> b >> n;
solve();
}
}
int main() {
read();
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long a, b, c, n;
int main() {
int t;
cin >> t;
while (t--) {
cin >> a >> b >> n;
c = a ^ b;
if (n % 3 == 1)
cout << b << endl;
else if (n % 3 == 2)
cout << c << endl;
else
cout << a << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll M = 1000000007;
const ll N = 998244353;
ll power(ll x, ll y, ll p) {
ll res = 1;
x = x % p;
if (x == 0) return 0;
while (y > 0) {
if (y & 1) res = (res * x) % p;
y = y >> 1;
x = (x * x) % p;
}
return res;
}
ll inv(ll x, ll m) { return power(x, m - 2, m); }
struct comp {
template <typename T>
bool operator()(const T &a, const T &b) {
if (a.first == b.first)
return (a.second < b.second);
else
return (a.first < b.first);
}
};
bool mod(const pair<ll, ll> &a, const pair<ll, ll> &b) {
if (a.first != b.first)
return (a.first > b.first);
else
return (a.second > b.second);
}
vector<bool> pr(1000000 + 1, 1);
void sieve(ll mn, ll mx) {
for (ll i = mn; i * i <= mx; i++)
if (pr[i - mn] == 1)
for (ll j = i * i; j <= mx; j += i) pr[j - mn] = 0;
}
bool isValid(ll i, ll j, ll t1, ll n, ll t2, ll m) {
if (i >= t1 && i < n && j >= t2 && j < m) {
return true;
}
return false;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, m, i, j, k, num, num1, num2, flag = 0;
int t;
cin >> t;
while (t--) {
ll n, m, i, j, k, num, num1, num2, flag = 0;
ll a, b;
cin >> a >> b >> n;
ll c = a ^ b;
vector<ll> v = {a, b, c};
cout << v[n % 3] << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int tc, cases;
long long n, a, b;
long long val[2][32];
long long add[32], temp, sol, bit[3] = {0, 1, 1};
int i, j;
scanf("%d", &cases);
for (tc = 0; tc < cases; tc++) {
scanf("%lld %lld %lld", &a, &b, &n);
if (n == 0) {
printf("%lld\n", a);
continue;
}
if (n == 1) {
printf("%lld\n", b);
continue;
}
temp = a;
for (i = 0; i < 32; i++) {
val[0][i] = temp % 2;
temp /= 2;
}
temp = b;
for (i = 0; i < 32; i++) {
val[1][i] = temp % 2;
temp /= 2;
}
for (i = 0; i < 32; i++) {
if (val[0][i] == 0 && val[1][i] == 0) {
add[i] = -1;
} else if (val[0][i] == 0 && val[1][i] == 1) {
add[i] = 0;
} else if (val[0][i] == 1 && val[1][i] == 1) {
add[i] = 1;
} else {
add[i] = 2;
}
}
temp = 1;
sol = 0;
for (i = 0; i < 32; i++) {
if (add[i] != -1) {
sol += temp * bit[(n + add[i]) % 3];
}
temp *= 2;
}
printf("%lld\n", sol);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void solve(int tnum) {
int a, b, n;
scanf("%d%d%d", &a, &b, &n);
if (n % 3 == 0) printf("%d\n", a);
if (n % 3 == 1) printf("%d\n", b);
if (n % 3 == 2) printf("%d\n", a ^ b);
}
int main() {
int tnum;
scanf("%d", &tnum);
for (int i = 1; i <= tnum; i++) solve(i);
}
|
#include <bits/stdc++.h>
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
std::cin >> t;
for (int i = 0; i < t; ++i) {
int a, b, n;
std::cin >> a >> b >> n;
if (n % 3 == 0) {
std::cout << a << "\n";
} else if (n % 3 == 1) {
std::cout << b << "\n";
} else {
std::cout << (a ^ b) << "\n";
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long int a, b, n;
cin >> a >> b >> n;
vector<long long int> fib;
fib.push_back(a);
fib.push_back(b);
fib.push_back(a ^ b);
cout << fib[n % 3] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
size_t ab[3], n, t;
cin >> t;
for (size_t i = 0; i < t; i++) {
cin >> ab[0] >> ab[1] >> n;
ab[2] = ab[1] ^ ab[0];
cout << ab[n % 3] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t, a, b, n, d;
cin >> t;
while (t--) {
cin >> a >> b >> n;
if (n % 3 == 0) {
cout << a << endl;
} else if (n % 3 == 1) {
cout << b << endl;
} else if (n % 3 == 2) {
d = a ^ b;
cout << d << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long a, b, n, ans = 0;
int main() {
int t;
cin >> t;
while (t--) {
cin >> a >> b >> n;
long long x = n % 3;
if (x == 0)
cout << a << endl;
else if (x == 1)
cout << b << endl;
else
cout << (a ^ b) << 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 == 2)
cout << (a ^ b) << '\n';
else if (n % 3 == 1)
cout << b << '\n';
else
cout << a << '\n';
}
}
|
#include <bits/stdc++.h>
long long a, b, n;
int main() {
int zz;
scanf("%d", &zz);
while (zz--) {
scanf("%lld%lld%lld", &a, &b, &n);
long long c = a ^ b;
long long t = n % 3;
if (t == 0) printf("%lld\n", a);
if (t == 1) printf("%lld\n", b);
if (t == 2) printf("%lld\n", c);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
template <typename dataType>
dataType nthGrayCode(dataType n) {
return (n ^ (n >> 1));
}
template <typename dataType>
void generateAllSubset(vector<dataType> &data) {
int i, j, n;
n = data.size();
for (i = 0; i < (1 << n); i++) {
for (j = 0; j < n; j++) {
if (i & (1 << j)) {
cout << data[j] << " ";
}
}
cout << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int test, a, b, n, r, ans;
cin >> test;
while (test--) {
cin >> a >> b >> n;
r = n % 3;
if (r == 0)
ans = a;
else if (r == 1)
ans = b;
else
ans = a ^ b;
cout << ans << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int tt;
cin >> tt;
while (tt--) {
int 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 main() {
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
c %= 3;
if (c == 0)
cout << a << endl;
else if (c == 1)
cout << b << endl;
else
cout << (a ^ b) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const unsigned long long hash1 = 201326611;
const int inf = 0x3f3f3f3f;
const int _inf = 0xc0c0c0c0;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long _INF = 0xc0c0c0c0c0c0c0c0;
const long long mod = (int)1e9 + 7;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long ksm(long long a, long long b, long long mod) {
int ans = 1;
while (b) {
if (b & 1) ans = (ans * a) % mod;
a = (a * a) % mod;
b >>= 1;
}
return ans;
}
long long inv2(long long a, long long mod) { return ksm(a, mod - 2, mod); }
void exgcd(long long a, long long b, long long &x, long long &y, long long &d) {
if (!b) {
d = a;
x = 1;
y = 0;
} else {
exgcd(b, a % b, y, x, d);
y -= x * (a / b);
}
}
inline int read() {
int date = 0, m = 1;
char ch = 0;
while (ch != '-' && (ch<'0' | ch> '9')) ch = getchar();
if (ch == '-') {
m = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
date = date * 10 + ch - '0';
ch = getchar();
}
return date * m;
}
int main() {
int t;
long long a, b, n;
scanf("%d", &t);
while (t--) {
scanf("%lld%lld%lld", &a, &b, &n);
if (n % 3 == 0) {
printf("%lld\n", a);
} else if (n % 3 == 1) {
printf("%lld\n", b);
} else {
printf("%lld\n", a ^ b);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const unsigned long long mod = 1e9 + 7;
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T> v) {
os << "(" << v.first << ", " << v.second << ")";
return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T> v) {
for (int i = 0; i < v.size(); i++) {
if (i > 0) {
os << " ";
}
os << v[i];
}
return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<vector<T>> v) {
for (int i = 0; i < v.size(); i++) {
if (i > 0) {
os << endl;
}
os << v[i];
}
return os;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
long long T;
cin >> T;
while (T--) {
long long a, b, n;
cin >> a >> b >> n;
long long p = (n % 3 == 1 ? 0 : a);
long long q = (n % 3 == 0 ? 0 : b);
cout << (p ^ q) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
void c_p_c() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
int main() {
c_p_c();
int x = 1;
cin >> x;
while (x--) {
int a, b, n;
cin >> a >> b >> n;
if (n == 0)
cout << a << endl;
else if (n == 1) {
cout << b << endl;
} else {
if ((n - 2) % 3 == 0) {
int c = a ^ b;
cout << c << endl;
} else if ((n - 2) % 3 == 1) {
cout << a << endl;
} else {
cout << b << endl;
}
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long a, b, c;
cin >> a >> b >> c;
if (c % 3 == 2) {
cout << (a ^ b) << endl;
} else if (c % 3 == 0) {
cout << (a) << endl;
} else {
cout << b << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
unsigned long long int t;
cin >> t;
while (t--) {
unsigned long long int a, b, n;
cin >> a >> b >> n;
unsigned long long int look[3];
look[0] = a;
look[1] = b;
look[2] = a ^ b;
if (n == 0) {
cout << a << endl;
continue;
}
if (n == 1) {
cout << b << endl;
continue;
}
if (n == 2) {
cout << look[2] << endl;
continue;
} else {
cout << look[n % 3] << endl;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
inline void filehandling() {}
vector<long long> vector_in(long long n) {
vector<long long> v(n);
for (long long i = 0; i < n; i++) cin >> v[i];
return v;
}
void vector_out(vector<long long> v) {
for (long long i = 0; i < v.size(); i++) cout << v[i] << " ";
cout << endl;
}
long long vector_sum(vector<long long> v) {
long long sum;
for (long long i = 0; i < v.size(); i++) sum += v[i];
return sum;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
filehandling();
long long T;
cin >> T;
while (T--) {
long long v1, v2, n, M = 0;
cin >> v1;
cin >> v2;
cin >> n;
if (n == 0) {
cout << v1 << endl;
continue;
}
if (n == 1) {
cout << v2 << endl;
continue;
}
for (long long i = 0; i < 32; i++) {
bool boolean = v1 & (1 << i), boolean1 = v2 & (1 << i);
if (boolean == 1 && boolean1 == 1) {
if (n % 3 != 2) M |= (1 << i);
} else if (boolean == 1 && boolean1 == 0) {
if (n % 3 != 1) M |= (1 << i);
} else if (boolean == 0 && boolean1 == 1) {
if (n % 3 != 0) M |= (1 << i);
}
}
cout << M << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int t, a, b, n;
cin >> t;
while (t--) {
cin >> a >> b >> n;
long long int x = 0;
x = a xor 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;
long long a, b, c, t, V[3];
int main() {
cin >> t;
while (t--) {
cin >> a >> b >> c;
V[0] = a;
V[1] = b;
V[2] = a ^ b;
cout << V[c % 3] << '\n';
}
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);
N = (N + 1) % 3;
printf("%d\n", N ? (N == 1 ? A : B) : A ^ B);
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int a, b, n, t;
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() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
int a, b, n;
cin >> t;
while (t--) {
cin >> a >> b >> n;
if (n % 3 == 1) a = 0;
if (n % 3 == 0) b = 0;
cout << (a ^ b) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const int N = 201010;
int main() {
ios_base::sync_with_stdio(0);
int test;
cin >> test;
while (test--) {
int n, a, b;
cin >> a >> b >> n;
int f[3] = {a, b, a ^ b};
cout << f[n % 3] << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int solve(int a, int b, int n) {
n %= 3;
if (n == 0) {
return a;
} else if (n == 1) {
return b;
} else {
return a ^ b;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T, a, b, n;
cin >> T;
while (T--) {
cin >> a >> b >> n;
int result = solve(a, b, n);
cout << result << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef map<int, int> mii;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vii;
typedef vector<ll> vll;
int main() {
cin.sync_with_stdio(0);
cin.tie(0);
cin.exceptions(cin.failbit);
int t;
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int arr[] = {a, b, (a ^ b)};
cout << arr[c % 3] << "\n";
}
}
|
#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(228);
using namespace std;
const long long mod = 1e9 + 7, inf = 1e9;
int main() {
long long t;
cin >> t;
for (int i = 0; i < t; ++i) {
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;
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long a, b, c;
cin >> a >> b >> c;
if (c % 3 == 2) {
cout << (a ^ b) << endl;
} else if (c % 3 == 0) {
cout << a << endl;
} else
cout << 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;
int a, b, n;
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';
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
const long long N = 1234567;
const long long mod = 1e9 + 7;
long long n;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.precision(10);
int t;
cin >> t;
while (t--) {
long long a, b;
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 test, a[3], n;
int main() {
cin >> test;
while (test--) {
cin >> a[0] >> a[1] >> n;
a[2] = a[0] ^ a[1];
cout << a[n % 3] << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long COUNT = 0;
int tmp[100005];
int main() {
int t;
scanf("%d", &t);
while (t--) {
int a, b, n;
scanf("%d%d%d", &a, &b, &n);
if (n % 3 == 2) {
printf("%d\n", a ^ b);
} else if (n % 3 == 0) {
printf("%d\n", a);
} else {
printf("%d\n", b);
}
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
long long N = 500005;
long long MAX = 9223372036854775807;
long long MOD = 1000000007;
long double PI = 4 * atan(1);
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
cout.precision(30);
long long n, m, k, a, b, c, x, y;
int t;
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";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
;
int t;
cin >> t;
while (t--) {
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;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, j;
cin >> t;
for (j = 0; j <= t - 1; j++) {
int a, b, c, n;
cin >> a >> b >> n;
n = n % 3;
c = a ^ b;
if (n == 0) {
cout << a << endl;
} else if (n == 1) {
cout << b << endl;
} else {
cout << c << endl;
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int T;
int a, b, n;
cin >> T;
int mem[3];
while (T--) {
cin >> a >> b >> n;
mem[0] = a;
mem[1] = b;
mem[2] = a ^ b;
n %= 3;
cout << mem[n] << "\n";
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main(void) {
long long int test, a, b, n, c, j;
cin >> test;
while (test--) {
cin >> a >> b >> n;
c = a ^ b;
long long int ans[5] = {c, a, b};
j = n + 1;
cout << ans[j % 3] << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;
priority_queue<int, vector<int>, greater<int> > pq;
vector<int> v;
int main() {
int t;
scanf("%d", &t);
while (t--) {
int a, b, n;
scanf("%d %d %d", &a, &b, &n);
if (n % 3 == 0) {
printf("%d\n", a);
}
if (n % 3 == 1) {
printf("%d\n", b);
}
if (n % 3 == 2) {
printf("%d\n", a ^ b);
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long md = 1000000007;
int main() {
int t;
cin >> t;
while (t--) {
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 << 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;
switch (n % 3) {
case 0:
cout << a << "\n";
break;
case 1:
cout << b << "\n";
break;
default:
cout << (a ^ b) << "\n";
}
}
}
|
#include <bits/stdc++.h>
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
cerr << '{';
__print(x.first);
cerr << ',';
__print(x.second);
cerr << '}';
}
template <typename T>
void __print(const T &x) {
int f = 0;
cerr << '{';
for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
__print(t);
if (sizeof...(v)) cerr << ", ";
_print(v...);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t, a, b, n;
cin >> t;
while (t--) {
cin >> a >> b >> n;
if (n == 0) {
cout << a << endl;
} else if (n == 1) {
cout << b << endl;
} else if (n == 2) {
cout << (a ^ b) << endl;
} else {
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() {
long long a, b, n, t;
cin >> t;
while (t--) {
cin >> a >> b >> n;
n++;
n %= 3;
long long ans = a;
ans ^= b;
if (n == 0) cout << ans << endl;
if (n == 1) cout << a << endl;
if (n == 2) cout << b << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
for (int k = 0; k < t; k++) {
long long int a, b, n, i;
cin >> a >> b >> n;
if (n % 3 == 2)
cout << (a ^ b) << endl;
else if (n % 3 == 0)
cout << a << endl;
else if (n % 3 == 1)
cout << b << endl;
}
}
|
#include <bits/stdc++.h>
using namespace std;
long long read() {
long long s = 0, w = 1;
char ch = getchar();
while (ch < '0' || ch > '9') {
if (ch == '-') w = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
s = s * 10 + ch - '0';
ch = getchar();
}
return s * w;
}
int main() {
int T = read();
while (T--) {
int a = read();
int b = read();
int n = read() % 3;
if (n == 0)
cout << a << endl;
else if (n == 1)
cout << b << endl;
else if (n == 2)
cout << (a ^ b) << endl;
}
return 0;
}
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long int a, b, n;
cin >> a >> b >> n;
if (n % 3 == 0)
cout << a << endl;
else if ((n - 1) % 3 == 0)
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--) {
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 << ((long long int)a ^ b) << '\n';
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.