一、题目
二、分析
枚举所有错误的情况,得到所有可能的数字。
当二进制枚举的数=三进制枚举的数时即可得到答案。
三、代码
#include <bits/stdc++.h>
using namespace std;
map<long long, bool> M;
long long get(string op, int b)
{
int res = 0;
for (int i = 0; i < op.size(); i++)
res = res * b + op[i] - '0';
return res;
}
int main()
{
string ch1, ch2;
cin >> ch1 >> ch2;
for (int i = 0; i < ch1.size(); i++)
{
ch1[i] ^= 1;
M[get(ch1, 2)] = true;
ch1[i] ^= 1;
}
for (int i = 0; i < ch2.size(); i++)
{
string op = ch2;
for (int j = 0; j <= 2; j++)
{
op[i] = j + '0';
if (M[get(op, 3)] && j + '0' != ch2[i])
{
cout << get(op, 3) << endl;
return 0;
}
}
}
return 0;
}