Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
93021 | LJY | 22破解密码 | C++ | Wrong Answer | 0 MS | 272 KB | 1708 | 2024-10-07 15:38:26 |
#include <iostream> #include <string> using namespace std; string decryptPassword(string encrypted) { string decrypted = ""; // 逐个字符检查,根据例子中的模式进行解密 for (int i = 0; i < encrypted.length();) { // 如果是以 "12345" 开头,则表示数字 '1' if (encrypted.substr(i, 5) == "12345") { decrypted += '1'; i += 5; } // 如果是以 "167" 开头,则表示数字 '4' else if (encrypted.substr(i, 3) == "167") { decrypted += '4'; i += 3; } // 如果是以 "51675" 开头,则表示数字 '6' else if (encrypted.substr(i, 5) == "51675") { decrypted += '6'; i += 5; } // 如果是以 "615" 开头,则表示数字 '5' else if (encrypted.substr(i, 3) == "615") { decrypted += '5'; i += 3; } // 如果是以 "573" 开头,则表示数字 '3' else if (encrypted.substr(i, 3) == "573") { decrypted += '3'; i += 3; } // 如果是以 "517" 开头,则表示数字 '5' else if (encrypted.substr(i, 3) == "517") { decrypted += '5'; i += 3; } else { // 处理可能未预料到的模式,直接跳过 i++; } } return decrypted; } int main() { string encrypted; cin >> encrypted; // 输入加密的密码字符串 string decrypted = decryptPassword(encrypted); cout << decrypted << endl; // 输出解密后的真实内容 return 0; }
------Input------
1234516751675615735173514
------Answer-----
146155534
------Your output-----
14655