- P14's solution
-
题解P14
- @ 2025-11-9 8:59:19
按题意直接模拟即可。
AC code:
// Paste your Program A here
#include <bits/stdc++.h>
using namespace std;
int main() {
string S;
cin >> S;
int X = 0;
for (int i = 0; i < S.size(); ++i) {
if (S[i] == '1') {
X ^= (i + 1);
}
}
cout << X << endl;
return 0;
}
/* ATTENTION!!! THIS IS THE BARRIER!!! */
// Paste your Program B here
#include <bits/stdc++.h>
using namespace std;
int main()
{
string T;
int X;
cin >> T >> X;
int D = 0;
int t_xor = 0;
for (int i = 0; i < T.size(); ++i) {
if (T[i] == '1') {
t_xor ^= (i + 1);
}
}
int diff = X ^ t_xor;
if (diff > 0 && diff <= T.size()) {
D = diff;
}
cout << D << endl;
return 0;
}