G 我码呢
正解可以参考出题人的题解
你需要做的有以下几步:
1.观察题目样例发现题目里的输出是对每位+1以后*4,再 % 10
2、反转原数字
3、去除前导0以后输出
但是队友手玩直接把规律玩出来了
map<char, char> mp = {{'0', '4'}, {'1', '8'}, {'2', '2'}, {'3', '6'}, {'4', '0'}, {'5', '4'}, {'6', '8'}, {'7', '2'}, {'8', '6'}, {'9', '0'}};
void init()
{
}
void Enolaly()
{
string s;
cin >> s;
string t;
for (auto &c : s)
{
t = mp[c] + t;
}
while (!t.empty() && t[0] == '0')
{
t.erase(0, 1);
}
if (t.empty())
{
cout << 0 << '\n';
}
else
{
cout << t << '\n';
}
}

京公网安备 11010502036488号