text
stringlengths
49
983k
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int x = 0; for (int i = 0; i < n; i++) if (s[i] == '1') x++; if (x + x == n) { cout << '2' << endl; cout << s.substr(0, n - 1) << " " << s[n - 1] << endl; } else { cout << '1' << endl; cout << s << endl; } }
#include <bits/stdc++.h> using namespace std; const int N = 2e5 + 5, M = 3, nBits = 2e8 + 5, MM = (1 << 16), MAX = 1111, OO = 0x3f3f3f3f, MOD = 1000000007, inf = 1 << 30; const double PI = acos(-1); const long long INF = (long long)1e18, MOOD = 1000000007; long long GCD(long long a, long long b) { return !b ? a : GCD(b, a % b); } long long LCM(long long x, long long y) { return (x * y / GCD(x, y)); } long long fact(long long z) { return (z <= 1) ? 1 : z * fact(z - 1); } void fast() { std::ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); } int t, q, n, m, c, d, x, y, z, a, b, cnt, A[N]; long long sum; string second, ss; deque<int> dq; vector<int> v; int main() { fast(); cin >> n >> second; for (int i = 0; i < n; ++i) if (second[i] == '1') ++x; else ++y; if (x == y) cout << "2\n" << second[0] << " " << second.substr(1) << endl; else cout << "1\n" << second << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int p[101]; for (int i = 0; i < sizeof(p) / 4; i++) p[i] = -2; int n; scanf("%d", &n); string s; cin >> s; int s_vert = -1; queue<int> bfs; bfs.push(s_vert); while (!bfs.empty()) { int cur_vert = bfs.front(); bfs.pop(); if (cur_vert == n - 1) break; int counter = 0; for (int next = cur_vert + 1; next < n; next++) { if (s[next] == '1') ++counter; else --counter; if (counter == 0) continue; bfs.push(next); if (p[next] == -2) { p[next] = cur_vert; } } } int vert = n - 1; stack<int> cuts; cuts.push(vert); while (vert != -1) { vert = p[vert]; cuts.push(vert); } printf("%d\n", cuts.size() - 1); while (cuts.size() > 1) { vert = cuts.top(); cuts.pop(); cout << s.substr(vert + 1, cuts.top() - vert) << " "; } return 0; }
#include <bits/stdc++.h> using namespace std; double const eps = 1e-8; using ll = long long; using ii = pair<int, int>; int n, m; string s; int main() { ios::sync_with_stdio(false); cin >> n; cin >> s; int ones = 0; int zeroes = 0; for (auto c : s) { if (c == '0') zeroes += 1; if (c == '1') ones += 1; } if (ones == zeroes) { cout << 2 << "\n"; cout << s[0] << " "; for (int i = 1; i < n; ++i) { cout << s[i]; } cout << endl; } else { cout << 1 << endl; for (int i = 0; i < n; ++i) { cout << s[i] << ""; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int t = 1; while (t--) { long long int n, i; cin >> n; string s; cin >> s; long long int c = 0, d = 0; for (i = 0; i < n; i++) { if (s[i] == '0') c++; else d++; } if (c != d) cout << 1 << "\n" << s << "\n"; else cout << 2 << "\n" << s[0] << " " << s.substr(1) << "\n"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long int n, c1 = 0, c2 = 0; cin >> n; string a; cin >> a; for (long long int i = 0; i < n; i++) { if (a[i] == '1') c1++; else c2++; } if (c1 != c2) { cout << "1\n" << a; } else { cout << "2\n" << a[0] << " "; for (long long int i = 1; i < n; i++) cout << a[i]; } }
#include <bits/stdc++.h> using namespace std; long long int mod = 998244353; bool checkGood(string s) { int c0 = 0, c1 = 0; for (int i = 0; i < s.length(); i++) { if ((int)s[i] - 48 == 1) c1++; else c0++; } if (c1 != c0) return 1; else return 0; } void solve() { int n; cin >> n; string s; cin >> s; int c = 1; if (checkGood(s)) { cout << c << '\n' << s; } else { c++; cout << c << '\n' << s.substr(0, n - 1) << " " << s[n - 1]; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; }
#include <bits/stdc++.h> using namespace std; bool sortbysec(const pair<long long int, long long int>& a, const pair<long long int, long long int>& b) { return (a.second < b.second); } long long int mpow(long long int x, long long int y) { long long int ans = 1; while (y) { if (y % 2 != 0) ans = (ans % 1000000007) * (x % 1000000007) % 1000000007; y /= 2; x = ((x % 1000000007) * (x % 1000000007)) % 1000000007; } return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long int n, a = 0, b = 0, i; cin >> n; string s; cin >> s; for (i = 0; i < s.size(); i++) if (s[i] - '0') a++; else b++; if (a != b) { cout << "1" << endl << s; } else { cout << "2" << endl << s[0] << " " << s.substr(1); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, c1 = 0, c2 = 0; cin >> n; string c; cin >> c; for (i = 0; i < n; i++) { if (c[i] == '1') c1++; else c2++; } if (c1 != c2) { cout << "1\n"; cout << c; } else { cout << "2\n"; cout << (c.substr(0, n - 1)) << " " << c[n - 1]; } return 0; }
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); long long tests = 1; while (tests--) { long long n; cin >> n; string s; cin >> s; if ((long long)s.length() == 1) { cout << "1" << '\n' << s; return 0; } long long y = 0; for (long long i = 0; i < (long long)s.length(); i++) { if (s[i] == '0') y++; } if (2 * y != (long long)s.length()) { cout << "1" << '\n' << s; return 0; } for (long long i = 0; i < (long long)s.length() - 1; i++) { string j = s.substr(0, i + 1); string k = s.substr(i + 1, (long long)s.length()); long long t = 0, x = 0; for (long long i = 0; i < (long long)j.length(); i++) { if (j[i] == '0') t++; } for (long long i = 0; i < (long long)k.length(); i++) { if (k[i] == '0') x++; } if (2 * t != (long long)j.length() && 2 * x != (long long)k.length()) { cout << "2" << '\n'; cout << j << " " << k; return 0; } } cout << "3" << '\n'; cout << s[0] << " " << s[1] << " " << s.substr(2, (long long)s.length()); } }
#include <bits/stdc++.h> using namespace std; const int MAXN = 4e5 + 10; char a[MAXN]; int i, n, ans, x; int main() { scanf("%d", &n); scanf("%s", a); for (i = 0; i < n; i++) { if (a[i] == '1') ans++; } if (ans != n - ans) { printf("1\n"); printf("%s\n", a); } else { printf("2\n"); printf("%c ", a[0]); for (i = 1; i < n; i++) printf("%c", a[i]); putchar(10); } }
#include <bits/stdc++.h> using namespace std; long long i, j, z, n, o; string s; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> s; for (i = 0; i < n; i++) { if (s[i] == '0') z++; else o++; } if (z != o) { cout << 1 << endl << s; return 0; } cout << 2 << endl << s[0] << " "; for (i = 1; i < n; i++) { cout << s[i]; } return 0; }
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int main() { int n; while (cin >> n) { string s; cin >> s; int pl = 0; for (auto i : s) { if (i == '0') pl++; else pl--; } if (pl == 0) { cout << 2 << endl; cout << s.substr(0, 1) << ' ' << s.substr(1, n - 1) << endl; } else { cout << 1 << endl; cout << s << endl; } } }
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; const long long SIZE = 100000; const int INF = 0x3f3f3f3f; const long long ll_INF = 0x3f3f3f3f3f3f3f3f; const long double PI = acos(-1); const long long MAXN = numeric_limits<long long>::max(); const long long MAX = 2000000; bool isprime(long long n) { if (n <= 1) return false; for (long long i = 2; i <= sqrt(n); i++) if (n % i == 0) return false; return true; } void disp(vector<long long> v) { for (auto u : v) cout << u << " "; cout << '\n'; } void solve() { int n; cin >> n; int one = 0, zro = 0; string s; cin >> s; for (long long i = 0; i < n; i++) { if (s[i] == '1') one++; else zro++; } if (one != zro) cout << 1 << "\n" << s; else { cout << 2 << "\n"; cout << s[0] << " "; s.erase(0, 1); cout << s; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); solve(); return 0; }
#include <bits/stdc++.h> #pragma GCC optimize("-O2") using namespace std; const int LIM = 1e5 + 5, MOD = 1e9 + 7; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n, one = 0, zero = 0; cin >> n; string s; cin >> s; for (int i = 0; i < s.size(); ++i) { if (s[i] == '0') zero++; else if (s[i] == '1') one++; } if (zero == one) { cout << "2" << '\n'; cout << s[0] << " "; for (int i = 1; i < s.size(); ++i) cout << s[i]; } else { cout << "1" << '\n'; cout << s << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, count = 0, count1 = 0; cin >> n; string s; cin >> s; for (int i = 0; i < n; i++) { if (s[i] == '0') count++; if (s[i] == '1') count1++; } if (count != count1) { cout << 1 << endl; cout << s; } else { cout << 2 << endl; cout << s[0] << " "; cout << s.substr(1, n - 1); } return 0; }
#include <bits/stdc++.h> int main() { int n, um = 0; char str[110]; scanf("%d\n", &n); for (int i = 0; i < n; i++) { scanf("%c", &str[i]); if (str[i] == '1') um++; else um--; } if (um != 0) { printf("1\n"); for (int i = 0; i < n; i++) { printf("%c", str[i]); } printf("\n"); } else { printf("2\n"); for (int i = 0; i < n - 1; i++) { printf("%c", str[i]); } printf(" %c\n", str[n - 1]); } return 0; }
#include <bits/stdc++.h> using namespace std; void input(long long int n, long long int arr[]) { for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n)); i += 1 - 2 * ((0) > (n))) cin >> arr[i]; } long long int sum(long long int n) { long long int sum = 0; long long int x = n; while (x) sum += (x % 10), x /= 10; return sum; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n; string s; cin >> n >> s; int one = 0, two = 0; for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n)); i += 1 - 2 * ((0) > (n))) if (s[i] == '1') one++; else two++; if (one == two) { cout << 2 << endl; for (__typeof(s.size() - 1) i = (0) - ((0) > (s.size() - 1)); i != (s.size() - 1) - ((0) > (s.size() - 1)); i += 1 - 2 * ((0) > (s.size() - 1))) cout << s[i]; cout << " " << s[s.size() - 1] << endl; } else { cout << 1 << endl << s << endl; } }
#include <bits/stdc++.h> using namespace std; int n, zer, on; int main() { string v; cin >> n >> v; for (int i = 0; i < n; i++) { if (v[i] == '1') on++; else zer++; } if (zer != on) { puts("1"); cout << v << endl; return 0; } puts("2"); cout << v[0] << " "; for (int i = 1; i < n; i++) cout << v[i]; cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; long long unu, zero, n; string s; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; cin >> s; for (int i = 0; i < s.size(); i++) { unu += s[i] == '1'; zero += s[i] == '0'; } if (unu == zero) { cout << 2 << '\n'; cout << s.substr(0, s.size() - 1) << " " << s.substr(s.size() - 1, 1); return 0; } cout << 1 << '\n'; cout << s; return 0; }
#include <bits/stdc++.h> #pragma warning(disable : 4996) using namespace std; const int maxn = 1e5 + 10; const int N = 2e6 + 100; char s[maxn]; int main() { int n; scanf("%d", &n); scanf("%s", s + 1); int one = 0, zero = 0; for (int i = 1; i <= n; ++i) { if (s[i] == '1') ++one; else ++zero; } if (zero != one) { printf("1\n%s\n", s + 1); } else { printf("2\n"); printf("%c %s\n", s[1], s + 2); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; char s[n]; cin >> s; if (n == 1) cout << 1 << endl << s; else { if (count(s, s + n, '1') != count(s, s + n, '0')) cout << 1 << endl << s; else { cout << 2 << endl; for (int i = 0; i < n - 1; i++) putchar(s[i]); cout << " " << s[n - 1]; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; string s; cin >> n >> s; int sum = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') { sum++; } else { sum--; } } if (sum == 0) { cout << 2 << endl << s.substr(0, n - 1) << " " << s[n - 1] << endl; } else { cout << 1 << endl << s << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { string s; int n; cin >> n >> s; int c1 = 0, c0 = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') c1++; else c0++; } if (c1 != c0) cout << "1\n" << s; else { cout << "2\n"; for (int i = 0; i < n - 1; i++) cout << s[i]; cout << " "; cout << s[n - 1]; } return 0; }
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const long long int INF = 1e12; long long int mod(long long int a) { if (a >= 0) return a; else return (-1 * a); } void swap(long long int a, long long int b) { long long int temp = a; a = b; b = temp; } long long int power(long long int a, long long int b) { long long int result = 1; while (b) { if (b % 2) result = (result % MOD) * (a % MOD); a = ((a % MOD) * (a % MOD)) % MOD; b = b / 2; } return result; } bool power_check(long long int a) { bool ans = true; while (a > 1) { if (a % 2 == 0) { a = a / 2; } else { ans = false; break; } } return ans; } void solve() { int n; cin >> n; string s; cin >> s; int c = 0; for (int i = 0; i < n; ++i) { if (s[i] == '0') c++; } if (c != n - c) { cout << 1 << "\n"; cout << s << "\n"; return; } cout << 2 << "\n"; cout << s[0] << " "; for (int i = 1; i < n; ++i) { cout << s[i]; } cout << "\n"; return; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int qqq; qqq = 1; while (qqq--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int one = 0, zero = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == '0') zero++; else one++; } if (one != zero) { cout << 1 << endl; cout << s << endl; } else { cout << 2 << endl; cout << s[0] << " " << s.substr(1); cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int o = 0, z = 0; for (char a : s) { if (a == '1') { o++; } else { z++; } } if (z == 0 || o == 0 || z != o) { cout << 1 << endl; cout << s << endl; return 0; } int i = 0; cout << 2 << endl; cout << s[i]; if (s[i] == '0') { z--; } else { o--; } i++; while (i < n && o == z) { cout << s[i]; i++; if (s[i] == '0') { z--; } else { o--; } } cout << " "; while (i < n) { cout << s[i]; i++; } cout << endl; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; int n, i; string s; cin >> n; cin >> s; int co1 = 0, co = 0; for (i = 0; i < n; i++) { if (s[i] == '0') co++; else co1++; } if (co != co1) { cout << 1 << endl; cout << s; } else { cout << 2 << endl; cout << s[0] << " "; for (i = 1; i < n; i++) cout << s[i]; } return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 105; const int INF = 0x3f3f3f3f; char s[MAXN]; int cnt[2]; int main() { int n; scanf("%d", &n); scanf("%s", s + 1); cnt[0] = cnt[1] = 0; for (int i = 1; i <= n; ++i) { ++cnt[s[i] - '0']; } if (cnt[0] != cnt[1] || cnt[0] == 0 || cnt[1] == 0) { printf("1\n"); printf("%s", s + 1); } else { printf("2\n"); printf("%c ", s[1]); printf("%s\n", s + 2); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, cnt = 0; string s; cin >> n >> s; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') { cnt++; } } if (cnt * 2 == s.size()) { cout << 2 << "\n" << s[0] << " "; } else { cout << 1 << "\n" << s[0]; } for (int i = 1; i < s.size(); i++) { cout << s[i]; } }
#include <bits/stdc++.h> using namespace std; int main() { int i, n; scanf("%d", &n); int s[n]; for (i = 0; i < n; i++) { scanf("%1d", &s[i]); } int c, d; c = d = 0; for (i = 0; i < n; i++) { if (s[i] == 1) { c++; } else { d++; } } if (c != d) { printf("1\n"); for (i = 0; i < n; i++) { printf("%d", s[i]); } } else { printf("2\n"); printf("%d ", s[0]); for (i = 1; i < n; i++) { printf("%d", s[i]); } } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; int main(void) { int n; char st[110]; scanf("%d %s", &n, st); int a = 0, b = 0; for (int i = 0; st[i] != '\0'; i++) { if (st[i] == '1') a++; if (st[i] == '0') b++; } if (a != b) { cout << "1" << endl; puts(st); } else { cout << "2" << endl; cout << st[0] << " "; for (int i = 1; st[i] != '\0'; i++) { cout << st[i]; } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int z = 0, o = 0; for (char &c : s) { if (c == '0') ++z; else ++o; } if (z == o) { char const c = s.back(); s.pop_back(); cout << "2\n" << s << " " << c; } else { cout << "1\n" << s << "\n"; } }
#include <bits/stdc++.h> using namespace std; int main() { string s; long long int n; cin >> n; cin >> s; long long int count0 = 0, count1 = 0; for (long long int i = 0; i < s.length(); i++) { if (s[i] - 48) { count1++; } else count0++; } if (count0 == count1) { long long int i = 0, j = 0; string s2 = "", s1 = ""; s2 = s[0]; for (long long int i = 1; i < s.length(); i++) { s1 += s[i]; } cout << 2 << "\n"; cout << s2 << " " << s1 << "\n"; } else { cout << 1 << "\n"; cout << s << "\n"; } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cin.get(); string str; getline(cin, str); int count_zero = 0, count_one = 0; for (int i = 0; i < str.length(); i++) { if (str[i] == '1') { count_one++; } else { count_zero++; } } if (count_zero == count_one) { bool ok; int temp = count_one; cout << 2 << endl; count_zero = count_one = 0; for (int i = 0; i < str.length(); i++) { ok = true; str[i] == '1' ? count_one++ : false; str[i] == '0' ? count_zero++ : false; if ((i == str.length() / 2 - 1) && (temp - count_one != temp - count_zero)) { ok = false; cout << str[i] << ' '; } else if ((i == str.length() / 2 - 1) && (temp - count_one == temp - count_zero)) { ok = false; cout << str[i] << str[i + 1] << ' '; i++; } if (ok) cout << str[i]; } } else { cout << 1 << endl; cout << str << endl; } }
#include <bits/stdc++.h> using namespace std; int main() { string s; int n, z = 0, o = 0; cin >> n >> s; for (int i = 0; i < s.size(); i++) { if (s[i] - '0' == 0) z++; else o++; } if (z != o || z > 0 && o == 0 || o > 0 && z == 0) { cout << 1 << endl; cout << s << endl; } else { cout << 2 << endl; cout << s[0] << " "; for (int i = 1; i < n; i++) cout << s[i]; cout << endl; } }
#include <bits/stdc++.h> using namespace std; long long n, a[107], c, b, d; string s, m; int main() { cin >> n; cin >> s; for (int i = 0; i < s.length(); i++) { if (s[i] == '1') d++; else d--; } if (d != 0) cout << 1 << endl << s; else { for (int i = 1; i < n; i++) { m = s.substr(0, i); for (int j = 0; j < m.length(); j++) { if (m[j] == '1') d++; else d--; } if (d != 0) { cout << 2 << endl << m << " " << s.substr(i, n - i); break; } d = 0; } } return 0; }
#include <bits/stdc++.h> using namespace std; signed main() { std ::ios_base ::sync_with_stdio(0); cin.tie(0); cout.tie(0); ; long long n; cin >> n; string s; cin >> s; long long a[2] = {0}; for (long long i = 0; i < n; i++) a[s[i] - 48]++; if (a[0] == a[1]) { cout << "2\n" << s[0] << " "; for (long long i = 1; i < n; i++) cout << s[i]; } else { cout << "1\n" << s; } }
#include <bits/stdc++.h> using namespace std; bool sec(char &a, char &b) { return (int(a) < int(b)); } long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); } long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); } void solve() { long long n, m = 0, t = 0, k = 0, x = 0, y = 0; string s; cin >> n >> s; for (long long i = 0; i < n; i++) { if (s[i] == '0') x++; else y++; } if (n % 2 == 1 || x != y) { cout << 1 << '\n' << s; return; } cout << 2 << '\n'; cout << s[0] << ' '; for (long long i = 1; i < n; i++) cout << s[i]; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int TESTS = 1; while (TESTS--) { solve(); } return 0; }
#include <bits/stdc++.h> using namespace std; int n; string s; int dem0, dem1; int main() { cin >> n; cin >> s; s = ' ' + s; if (n == 1) { cout << 1 << "\n" << s[n]; } else { for (int i = 1; i <= n; ++i) { if (s[i] == '1') dem1++; else dem0++; } if (dem1 != dem0) { cout << 1 << "\n"; for (int i = 1; i <= n; ++i) cout << s[i]; } else { cout << 2 << "\n"; cout << s[1] << " "; for (int i = 2; i <= n; ++i) cout << s[i]; } } }
#include <bits/stdc++.h> using namespace std; int main(int argc, char const* argv[]) { int n; cin >> n; char* s = (char*)malloc(sizeof(char) * (n + 1)); cin >> s; int num1 = 0, num2 = 0; for (int i = 0; i < n; i++) { if (s[i] == '0') num1++; else num2++; } if (num1 != num2) { cout << 1 << endl << s << endl; } else { cout << 2 << endl << s[0] << " " << s + 1 << endl; } free(s); 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; t = 1; while (t--) { int n; cin >> n; string s; cin >> s; int i, one = 0, zero = 0; for (i = 0; i < s.size(); i++) { if (s[i] == '1') one++; else zero++; } if (one != zero) { cout << "1\n"; cout << s << "\n"; } else { cout << "2\n"; for (i = 0; i < n - 1; i++) cout << s[i]; cout << " "; cout << s[n - 1]; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; string s; cin >> s; int cnt = 0; for (auto i : s) { if (i == '0') cnt++; } if (cnt * 2 == n) { cout << 2 << endl << s[0] << ' ' << s.substr(1, s.size() - 1); } else cout << 1 << endl << s; return 0; }
#include <bits/stdc++.h> using namespace std; bool isValid(string s) { long long int o = 0, z = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '0') z++; else o++; } if (z != o) return true; return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n; cin >> n; string s; cin >> s; if (isValid(s)) { cout << 1 << endl; cout << s << endl; return 0; } cout << 2 << endl; for (int i = 0; i < s.size(); i++) { if (isValid(s.substr(0, i + 1)) && isValid(s.substr(i, n - i - 1))) { cout << s.substr(0, i + 1) << " " << s.substr(i + 1, n - i - 1) << endl; return 0; } } return 0; }
#include <bits/stdc++.h> using namespace std; const long long INF = (1LL << 45LL); const long long MAXLL = 9223372036854775807LL; const unsigned long long MAXULL = 18446744073709551615LLU; const long long MOD = 1000000007; const long double DELTA = 0.000000001L; long long mpow(long long x, long long n1) { long long ret = 1; while (n1 > 0) { if (n1 % 2 == 1) ret = ret * x % MOD; x = x * x % MOD; n1 /= 2; } return ret; } long long inverse(long long x) { return mpow(x, MOD - 2); } long long dx[4] = {0, 0, 1, -1}; long long dy[4] = {1, -1, 0, 0}; long long _gcd(long long a, long long b) { if (b == 0) return a; return _gcd(b, a % b); } long long n; char A[100][100]; pair<long long, long long> s, e; bool chk(long long i, long long j) { if (i >= 0 && i < n && j >= 0 && j < n) return true; return false; } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL); long long n, m, k; cin >> n; string s; cin >> s; long long a = 0, b = 0; for (long long i = 0; i < (n); ++i) { if (s[i] == '0') { a++; } else { b++; } } if (a == b) { cout << 2 << endl; cout << s[0] << " "; for (long long i = 1; i <= (n - 1); ++i) { cout << s[i]; } cout << endl; } else { cout << 1 << endl; cout << s << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; long long n; void solve() { cin >> n; string s; cin >> s; long long cnt0 = 0, cnt1 = 0; for (auto i : s) { if (i == '0') ++cnt0; else ++cnt1; } if (cnt0 != cnt1) cout << 1 << '\n' << s << '\n'; else { string temp1, temp2; for (long long i = 1; i <= n - 1; i++) { temp1 = s.substr(0, i); temp2 = s.substr(i, n); cnt0 = 0, cnt1 = 0; for (auto i : temp1) { if (i == '0') ++cnt0; else ++cnt1; } if (cnt0 != cnt1) { cnt0 = 0, cnt1 = 0; for (auto i : temp2) { if (i == '0') ++cnt0; else ++cnt1; } } if (cnt0 != cnt1) break; } cout << 2 << '\n' << temp1 << ' ' << temp2 << '\n'; } } int main() { ios::sync_with_stdio(false); solve(); }
#include <bits/stdc++.h> using namespace std; int main() { int k; cin >> k; string s; cin >> s; int count = 0; for (int i = 0; i < k; ++i) if (s[i] == 49) ++count; if ((k % 2 == 0 && count != k / 2) || k % 2 != 0) { cout << "1" << "\n" << s; return 0; } if (k == 1) { cout << "1" << "\n" << "1"; return 0; } if (k % 2 == 0) { cout << "2" << "\n"; cout << s[0] << " "; cout << s.substr(1, k - 1); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int x = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') x++; } if (x + x == n) { cout << 2 << endl; cout << s.substr(0, n - 1) << " " << s[n - 1] << endl; } else { cout << 1 << endl; cout << s << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e5 + 10; int main() { int n, one = 0, zero = 0; cin >> n; string s; cin >> s; for (int i = 0; i < n; i++) { if (s[i] == '1') one++; else zero++; } if (one != zero) return cout << 1 << endl << s << endl, 0; int i = 0, onep = 0, zerop = 0; cout << 2 << endl; while (onep == zerop || one - onep == zero - zerop) { if (s[i] == '0') zerop++; else onep++; i++; } for (int j = 0; j < i; j++) cout << s[j]; cout << " "; for (int j = i; j < n; j++) cout << s[j]; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n; cin >> n; string s; cin >> s; int x = 0, y = 0; for (int i = 0; i < n; i++) { if (s[i] == '1') x++; else y++; } if (x != y) { cout << 1 << endl << s << endl; } else { cout << 2 << endl << s[0] << ' ' << s.substr(1, n - 1) << endl; } }
#include <bits/stdc++.h> using namespace std; long long fpow(long long n, long long k, long long p = 1000000007) { long long r = 1; for (; k; k >>= 1) { if (k & 1) r = r * n % p; n = n * n % p; } return r; } long long inv(long long a, long long p = 1000000007) { return fpow(a, p - 2, p); } long long Sqrt(long long x) { if (x == 0 || x == 1) return x; long long start = 1, end = x, ans; while (start <= end) { long long mid = (start + end) / 2; if (mid * mid == x) return mid; if (mid * mid < x) { start = mid + 1; ans = mid; } else end = mid - 1; } return ans; } long long power(long long x, long long y) { if (y == 0) return 1; else if (y % 2 == 0) return power(x, y / 2) * power(x, y / 2); else return x * power(x, y / 2) * power(x, y / 2); } long long gcd(long long a, long long b) { long long r; while (b) { r = a % b; a = b; b = r; } return a; } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } void in(long long &no) { bool neg = false; register long long c; no = 0; c = getchar(); if (c == '-') { neg = true; c = getchar(); } for (; (c > 47 && c < 58); c = getchar()) no = no * 10 + c - 48; if (neg) no *= -1; } int main() { long long n; cin >> n; string s; cin >> s; long long c = 0, d = 0; for (long long i = (0); i < (n); i++) { if (s[i] == '0') c++; if (s[i] == '1') d++; } if (c != d) cout << 1 << endl << s; else { cout << 2 << endl << s[0] << " "; for (long long i = (1); i < (n); i++) cout << s[i]; } return 0; }
#include <bits/stdc++.h> using namespace std; int check(string s, int i, int n) { int cnt1 = 0, cnt2 = 0, cnt3 = 0, cnt4 = 0; for (int x = 0; x < i; x++) { if (s[x] == '1') cnt1++; else cnt2++; } for (int x = i; x < n; x++) { if (s[x] == '1') cnt3++; else cnt4++; } if (cnt1 != cnt2 && cnt3 != cnt4) return 1; else return 0; } int main() { int n; cin >> n; string s; cin >> s; int p = 0, q = 0; for (int a = 0; a < n; a++) { if (s[a] == '1') p++; else q++; } if (p != q || n == 1) { cout << "1" << endl; cout << s; return 0; } int i; for (i = 1; i < n; i++) { if (check(s, i, n)) break; else continue; } cout << "2" << endl; for (int a = 0; a < i; a++) cout << s[a]; cout << " "; for (int a = i; a < n; a++) cout << s[a]; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string str; cin >> str; int c = count(str.begin(), str.end(), '0'); if (c == n / 2 && n % 2 == 0) { cout << 2 << endl; cout << str.at(0) << " " << str.substr(1, n - 1); } else cout << 1 << endl << str; return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 300010; int main() { char s[N]; int n; int sum = 0; cin >> n >> s; for (int i = 0; i < n; i++) { if (s[i] == '0') sum++; } if (sum == n / 2 && n % 2 == 0) cout << "2" << endl << s[0] << ' ' << s + 1 << endl; else cout << "1" << endl << s << endl; return 0; }
#include <bits/stdc++.h> int n; char s[105]; int cnt[105]; int main() { scanf("%d", &n); scanf("%s", &s[1]); for (int i = 1; i <= n; i++) { cnt[i] = cnt[i - 1] + (s[i] == '1' ? 1 : -1); } if (cnt[n] != 0) { printf("1\n"); printf("%s", &s[1]); } else { printf("2\n"); printf("%c %s", s[1], &s[2]); } return 0; }
#include <bits/stdc++.h> using namespace std; int n; string s; int main() { while (scanf("%d", &n) != EOF) { cin >> s; int len = s.length(); int cnt1 = 0; int cnt2 = 0; for (int i = 0; i < len; i++) { if (s[i] == '0') cnt1++; if (s[i] == '1') cnt2++; } if (cnt1 != cnt2) { cout << 1 << endl << s << endl; } else { cout << 2 << endl; cout << s[0] << " "; for (int i = 1; i < len; i++) cout << s[i]; cout << endl; } } }
#include <bits/stdc++.h> using namespace std; int main() { long long n, z = 0, o = 0; string s; cin >> n >> s; for (int i = 0; i < n; i++) { if (s[i] == '0') z++; else o++; } if (o != z) cout << 1 << endl << s; else { cout << 2 << endl << s[0] << " "; for (int i = 1; i <= n - 1; i++) { cout << s[i]; } } }
#include <bits/stdc++.h> using namespace std; int main() { int n, o = 0, z = 0; char a[105]; cin >> n; cin >> a; for (int i = 0; i < n; i++) { if (a[i] == '0') { z++; } else o++; } if (z != o) { printf("1\n"); printf("%s", a); } else { printf("2\n%c ", a[0]); for (int i = 1; i < n; i++) printf("%c", a[i]); } printf("\n"); return 0; }
#include <bits/stdc++.h> using namespace std; long long modex(long long x, long long n) { if (n == 0) return 1; else if (!(n & 1)) return modex((x * x) % 1000000007, n / 2); else return (x * modex((x * x) % 1000000007, (n - 1) / 2)) % 1000000007; } long long modinv(long long n) { return modex(n, 1000000007 - 2); } void bfs(vector<int> g[], int s, int n) { queue<long long> q; bool vis[n]; memset(vis, false, sizeof(vis)); vis[s] = true; q.push(s); while (!q.empty()) { long long temp = q.front(); q.pop(); for (auto it : g[temp]) { if (vis[it] == false) { q.push(it); vis[it] = true; } } } } void dfs(vector<int> g[], int src, bool vis[]) { vis[src] = true; for (auto it : g[src]) { if (vis[it] == false) { dfs(g, it, vis); } } } int main() { long long t; t = 1; while (t--) { long long n; cin >> n; string s; cin >> s; long long e = 0, o = 0; for (long long i = 0; i < n; i++) { if (s[i] == '0') o++; else e++; } if (o != e) { cout << 1 << endl << s; } else { cout << 2 << endl << s.substr(0, n - 1) << " " << s[n - 1]; } } return 0; }
#include <bits/stdc++.h> using namespace std; using namespace std; const int M = 1e9 + 7; const int MAXN = 5e5 + 1; int main() { int t; scanf("%d", &t); string s; cin >> s; int nz = 0, no = 0; for (char ch : s) { if (ch == '0') nz++; else no++; } if (nz != no) { cout << 1 << endl; cout << s << endl; } else { cout << 2 << endl; cout << s[0] << " " << s.substr(1, t - 1); } }
#include <bits/stdc++.h> using namespace std; void solve() { long long n; string s; cin >> n; cin >> s; if (n % 2 != 0) { cout << "1" << endl; cout << s; } else { long long cnt1 = 0, cnt0 = 0; for (long long i = 0; i < n; i++) { if (s[i] == '1') cnt1++; else cnt0++; } if (cnt1 != cnt0) { cout << "1" << endl; cout << s; } else { cout << "2" << endl; cout << s[0] << " "; for (long long i = 1; i < n; i++) cout << s[i]; } } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long long t; t = 1; while (t--) { solve(); } }
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s; cin >> s; int j = 0, k = 0; for (int i = 0; i < s.size(); i++) { if (s[i] == '1') { j++; } else { k++; } } if (k != j) { cout << "1" << endl; cout << s << endl; } else { cout << "2" << endl; for (int i = 0; i < s.size() - 1; i++) { cout << s[i]; } cout << " " << s[s.size() - 1]; } return 0; }
#include <bits/stdc++.h> void run(std::istream &in, std::ostream &out) { int n; in >> n; std::string s; in >> s; int ones = 0; int zeros = 0; for (char c : s) { if (c == '0') { zeros++; } else { ones++; } } if (ones != zeros) { out << 1 << "\n"; out << s << "\n"; } else { out << 2 << "\n"; std::string p1 = s.substr(0, 1); std::string p2 = s.substr(1); out << p1 << " " << p2 << "\n"; } } int main() { std::cin.sync_with_stdio(false); std::cin.tie(nullptr); run(std::cin, std::cout); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { for (int i = 1; i <= 1; ++i) { long long n, ans = 0, ans2 = 0; string s; cin >> n >> s; for (int i = 0; i < s.size(); ++i) { if (s[i] == '0') ans++; if (s[i] == '1') ans2++; } if (ans != ans2) { cout << 1 << "\n"; cout << s; } else { cout << 2 << "\n"; for (int i = 0; i < s.size() - 1; ++i) cout << s[i]; cout << " " << s[s.size() - 1]; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int n, i, z1 = 0, o1 = 0; string s; cin >> n >> s; for (i = 0; i < n; i++) { if (s[i] == '0') { z1++; } else if (s[i] == '1') { o1++; } } if (z1 != o1) { cout << 1 << endl << s; } else { cout << 2 << endl; cout << s[0] << " "; for (i = 1; i < n; i++) { cout << s[i]; } } cout << endl; }
#include <bits/stdc++.h> using namespace std; int k, l; int main() { int i, n; scanf("%d", &n); getchar(); char ch[1000]; scanf("%s", ch); for (i = 0; i < n; ++i) { if (ch[i] == '0') k++; else l++; } if (n % 2 == 1 || k != l) { printf("1\n%s\n", ch); return 0; } cout << 2 << endl; for (i = 0; i < n; ++i) { printf("%c", ch[i]); if (ch[i] == '0') k--; else l--; if (k == 0 || l == 0) break; } i++; cout << " "; for (int j = i; j < n; ++j) printf("%c", ch[j]); cout << endl; return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, a = 0, b = 0; cin >> n; string s; cin >> s; vector<string> ans; for (int i = 0; i < n; ++i) { a += (s[i] == '1'); b += (s[i] == '0'); } if (a != b) { cout << 1 << endl << s; } else { cout << 2 << endl; for (int i = 0; i < n - 1; ++i) { cout << s[i]; } cout << " " << s[n - 1]; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int64_t a, b, n, q; cin >> q; while (q--) { cin >> a >> b >> n; n %= 3; int pd[3]; pd[0] = a; pd[1] = b; pd[2] = pd[0] ^ pd[1]; cout << pd[n] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; long long a, b, c, n; int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b >> c; c %= 3; if (c == 0) cout << a << endl; else if (c == 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; 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, f1, f2, m; cin >> t; for (int i = 0; i < t; i++) { cin >> f1 >> f2 >> m; if (m % 3 == 0) { cout << f1 << endl; } else if (m % 3 == 1) { cout << f2 << endl; ; } else { cout << (f1 ^ f2) << endl; ; } } return 0; }
#include <bits/stdc++.h> using namespace std; long long gcd() { return 0ll; } template <typename T, typename... Args> T gcd(T a, Args... args) { return __gcd(a, (__typeof(a))gcd(args...)); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); long long T, i, j; 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"; } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int T; scanf("%d", &T); while (T--) { long long a, b, n; cin >> a >> b >> n; int ans = n % 3; if (ans == 2) cout << (a ^ b) << endl; else if (ans == 0) cout << a << endl; else cout << b << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) {} template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; err(++it, args...); } template <typename T> void cins(T &first) { cin >> first; } template <typename T, typename... Ts> void cins(T &first, T &second, Ts &...rest) { cin >> first; cins(second, rest...); } const long long mod = pow(10, 9) + 7; const long long N = 3e5; const long long inf = LLONG_MAX; const long long infn = LLONG_MIN; constexpr long long dx4[4] = {1, 0, -1, 0}; constexpr long long dy4[4] = {0, 1, 0, -1}; constexpr long long dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1}; constexpr long long dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1}; void iluzn() { long long a, b, n; cins(a, b, n); long long x[3] = {a, b, a ^ b}; cout << x[n % 3] << "\n"; } signed main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); long long t = 1; cin >> t; while (t--) iluzn(); 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 res[3] = {a, b, a ^ b}; cout << res[n % 3] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(0); cin.tie(nullptr); int t; cin >> t; while (t--) { int a, b, c; cin >> a >> b >> c; if (c % 3 == 0) { cout << a << '\n'; continue; } if (c % 3 == 1) cout << b << '\n'; else cout << (a ^ b) << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 11; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; for (int i = 1; i <= t; i++) { int a, b, n; cin >> a >> b >> n; if (n == 0) { cout << a << "\n"; continue; } if (n == 1) { cout << b << "\n"; continue; } int ans = 0; for (int j = 1, t = 0; t <= 30; t++, j *= 2) { int c1 = 0, c2 = 0; if ((a & j)) c1 = 1; if ((b & j)) c2 = 1; if (c1 == 1 && c2 == 1 && n % 3 != 2) ans += j; else if (c1 == 1 && c2 == 0 && n % 3 != 1) ans += j; else if (c1 == 0 && c2 == 1 && n % 3 != 0) ans += j; } cout << ans << "\n"; } }
#include <bits/stdc++.h> using namespace std; void solve() { long long int a, b, n, ans, i, f2 = 0; cin >> a >> b >> n; ans = a ^ b; if (n % 3 == 0) { cout << a << endl; return; } else if (n % 3 == 2) { cout << ans << endl; return; } else cout << b << endl; } int main() { long long int t; cin >> t; while (t--) solve(); return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t; long long a, b, n; 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> #pragma GCC optimize("O3") using namespace std; const int N = 200000; int tests, n, a, b, f[N]; int main() { ios_base::sync_with_stdio(0); cin >> tests; for (; tests; --tests) { cin >> a >> b >> n; if (n % 3 == 0) { cout << a; } if (n % 3 == 1) { cout << b; } if (n % 3 == 2) { cout << (a ^ b); } cout << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int t, a, b, n; int main() { cin >> t; while (t--) { cin >> a >> b >> n; switch (n % 3) { case 0: cout << a; break; case 1: cout << b; break; default: cout << (a ^ b); break; } cout << '\n'; } }
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { long long a, b, n, c; cin >> a >> b >> n; c = b ^ a; if (n % 3 == 0) cout << a << '\n'; else if (n % 3 == 1) cout << b << '\n'; else cout << c << '\n'; } }
#include <bits/stdc++.h> using namespace std; long long int t, i, j, n, ans, a, b, t1, t2; int main() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); ; cin >> t; while (t--) { cin >> a >> b >> n; if ((n % 3) == 0) { cout << a << '\n'; } else if ((n % 3) == 1) { cout << b << '\n'; } else { ans = a ^ b; cout << ans << '\n'; } } return 0; }
#include <bits/stdc++.h> using namespace std; bool test = 1; void solve() { int n, a, b; cin >> a >> b >> n; if (n % 3 == 0) { cout << a << endl; } else if (n % 3 == 1) { cout << b << endl; } else { int tmp = a ^ b; cout << tmp << endl; } } int main() { ios::sync_with_stdio(0); cout.tie(0); cin.tie(0); if (test) { int t; cin >> t; while (t--) solve(); } else 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; if (n % 3 == 0) cout << a << endl; else if (n % 3 == 1) cout << b << endl; else { int ans = a ^ b; cout << ans << endl; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t, a, b; long long n; cin >> t; while (t--) { cin >> a >> b >> n; if ((n + 1) % 3 == 0) printf("%d\n", a ^ b); else if ((n + 2) % 3 == 0) printf("%d\n", b); else printf("%d\n", a); } return 0; }
#include <bits/stdc++.h> using namespace std; int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}; int dy[] = {1, 0, -1, 0, 1, -1, 1, -1}; long long fix_mod(long long x, long long y) { return (y + x % y) % y; } void fast() { std::ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); } int main() { fast(); int t; long long a, b, n; 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() { long long int test, n, m, i, j, k, l, o; cin >> test; while (test--) { cin >> n >> l >> m; m = m % 3; if (m == 0) { cout << n << "\n"; } else if (m == 1) { cout << l << "\n"; } else { cout << (n ^ l) << "\n"; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int a, b, n, i, t, r = 0; while (cin >> t) { for (i = 0; i < t; i++) { cin >> a >> b >> n; if (n % 3 == 1) cout << b << endl; else if (n % 3 == 0) cout << a << endl; else { r = a ^ b; cout << r << endl; r = 0; } } } return 0; }
#include <bits/stdc++.h> using namespace std; int32_t main() { ios_base::sync_with_stdio(false); int test; cin >> test; while (test--) { int a, b, n; cin >> a >> b >> n; int c = a ^ b; vector<int> d = {a, b, c}; cout << d[n % 3] << '\n'; } return 0; }
#include <bits/stdc++.h> using namespace std; int f[3]; int main() { int t, a, b, n; scanf("%d", &t); while (t--) { scanf("%d%d%d", &a, &b, &n); f[0] = a; f[1] = b; f[2] = a ^ b; printf("%d\n", f[n % 3]); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { long long t, i; cin >> t; while (t--) { long long a, b, n, c; 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; const long long N = 1e5 + 10; const long long LOGMAX = 105; const long long inf = 1e9; bool _cmp(pair<long long, long long> f, pair<long long, long long> s) { return f.first + f.second > s.first + s.second; } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long T; cin >> T; while (T--) { long long a[3]; long long n; 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 a, b, n; int T; cin >> T; while (T--) { cin >> a >> b >> n; int ans = 0; if (n % 3 != 1) ans = ans ^ a; if (n % 3) ans = ans ^ b; cout << ans << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; namespace io { const int SI = 1 << 21 | 1; char IB[SI], *IS, *IT, OB[SI], *OS = OB, *OT = OS + SI - 1, c, ch[100]; int f, t; inline void flush() { fwrite(OB, 1, OS - OB, stdout), OS = OB; } inline void pc(char x) { *OS++ = x; if (OS == OT) flush(); } template <class I> inline void rd(I &x) { for (f = 1, c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++); c < '0' || c > '9'; c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)) if (c == '-') f = -1; for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + (c & 15), c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)) ; x *= f; } inline void rds(char *s, int &x) { for (c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++); c < '0' || c > '9'; c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)) ; for (x = 0; c >= '0' && c <= '9'; s[++x] = c, c = (IS == IT ? (IT = (IS = IB) + fread(IB, 1, SI, stdin), IS == IT ? EOF : *IS++) : *IS++)) ; s[x + 1] = '\0'; } template <class I> inline void print(I x, char k = '\n') { if (!x) pc('0'); if (x < 0) pc('-'), x = -x; while (x) ch[++t] = x % 10 + '0', x /= 10; while (t) pc(ch[t--]); pc(k); } struct Flush { ~Flush() { flush(); } } flusher; } // namespace io using io::print; using io::rd; using io::rds; namespace Rd { inline bool gt() { int a = rand(), b = rand(); while (a == b) a = rand(), b = rand(); return a < b; } template <class I> inline I Rand(I k) { I w = 1; while (w < k) w <<= 1; while (w >= k) { I o = 1, x = 0; while (o < k) o <<= 1, x = (x << 1) + gt(); w = x; } return w; } template <class I> inline I rdm(I l, I r) { return l + Rand(r - l + 1); } template <class I> inline void rdms(I *a, int n) { pair<int, I> p[n + 1]; map<int, bool> m; m.clear(); for (int i = 1; i <= n; i++) { int o = rdm(0, 1000000000); while (m[o]) o = rdm(0, 1000000000); m[o] = 1; p[i] = make_pair(o, a[i]); } sort(p + 1, p + n + 1); for (int i = 1; i <= n; i++) a[i] = p[i].second; } } // namespace Rd using Rd::gt; using Rd::rdm; using Rd::rdms; namespace kc { template <class I> inline I Min(I x, I y) { return x < y ? x : y; } template <class I> inline I Max(I x, I y) { return x > y ? x : y; } template <class I> inline void Swp(I &x, I &y) { x ^= y ^= x ^= y; } template <class I> inline I Abs(I x) { return x >= 0 ? x : -x; } } // namespace kc using kc::Abs; using kc::Max; using kc::Min; using kc::Swp; namespace Md { const int P = 1e9 + 7; inline int Add(int a, int b) { return a + b >= P ? a + b - P : a + b; } inline int Sub(int a, int b) { return a - b < 0 ? a - b + P : a - b; } inline int Mul(int a, int b) { return 1ll * a * b % P; } inline int ksm(int a, long long b = P - 2) { b %= P - 1; int c = 1; while (b) { if (b & 1) c = Mul(c, a); a = Mul(a, a), b >>= 1; } return c; } inline int Div(int a, int b) { return 1ll * a * ksm(b) % P; } } // namespace Md using Md::Add; using Md::Div; using Md::ksm; using Md::Mul; using Md::Sub; int main() { int T; rd(T); while (T--) { int a[3], n; rd(a[0]), rd(a[1]), rd(n); a[2] = a[0] ^ a[1]; print(a[n % 3]); } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t, a, b, n; cin >> t; for (int ii = 1; ii <= t; ii++) { 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> int main() { long long int a, b, n, t; scanf("%d", &t); while (t--) { scanf("%lld %lld %lld", &a, &b, &n); n %= 3; if (n == 0) { printf("%lld\n", a); } else if (n == 1) { printf("%lld\n", b); } else { printf("%lld\n", a ^ b); } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); 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; case 2: cout << (a ^ b) << '\n'; break; } } return 0; }
#include <bits/stdc++.h> using namespace std; int main() { int t, i; long long f[3], n; cin >> t; for (i = 1; i <= t; i++) { cin >> f[0] >> f[1] >> n; f[2] = f[0] ^ f[1]; cout << f[n % 3] << endl; } return 0; }
#include <bits/stdc++.h> using namespace std; int nthXorFib(int n, int a, int b) { if (n == 0) return a; if (n == 1) return b; if (n == 2) return (a ^ b); return nthXorFib(n % 3, a, b); } int main() { int a, b, n, t; cin >> t; while (t--) { cin >> a >> b >> n; cout << nthXorFib(n, a, b) << endl; } return 0; }