131 条题解
-
-1
Daqu LV 5 @ 2017-05-28 13:26:53
不难,分别算出解密的字符串,然后嵌套循环验证即可,注意k的范围
#include<iostream> #include<string> std::string* input(); std::string compute1(std::string str); std::string compute2(std::string str, int k); std::string compute3(std::string str, int k); std::string check(std::string str[]); int main() { std::string *test = input(); std::cout << check(test) << std::endl; return 0; } std::string* input() { using namespace std; int n; cin >> n; string *str = new string[3]; cin >> str[0]; cin >> str[1]; cin >> str[2]; return str; } std::string compute1(std::string str) { using namespace std; string result; for(int i = str.size() - 1;i >= 0;i--) { result.append(string(1, str.at(i))); } return result; } std::string compute2(std::string str, int k) { using namespace std; string result(str.size(), '0'); for(int i = 0, n = str.size();i < n;i++) { int check = (int)str.at(i) + k; if(check > (int)('z')) { result.at(i) = (char)(check % (int)('z') + (int)('a') - 1); }else { result.at(i) = (char)(check); } } return result; } std::string compute3(std::string str, int k) { using namespace std; string result(str.size(), '0'); for(int i = 0;i < (int)str.size();i++) { int check = (int)str.at(i) - k; if(check < (int)('a')) { result.at(i) = (char)((int)('z') - (int)('a') + check + 1); }else { result.at(i) = (char)(check); } } return result; } std::string check(std::string str[]) { using namespace std; string str1, str2, str3; for(int x = 0;x < 3;x++) for(int y = 0;y < 3;y++) for(int z = 0;z < 3;z++) for(int k = 0;k <= 6;k++) { if(x != y && x != z && y != z) { if(compute1(str[x]) == compute2(str[y], k) && compute1(str[x]) == compute3(str[z], k)) { return compute1(str[x]); } }else { continue; } } return "fail"; } -
-1@ 2009-09-23 19:16:20
其实。。真的很强大。。我没有模拟各个串。。竟然过了。
-
-2@ 2017-07-01 17:13:11
天啊 k竟然可以等于0!!!
-
-2@ 2008-09-21 16:48:10
= =
我最慢 -
-2@ 2008-09-21 16:47:02
过了过了
-
-2@ 2008-09-21 16:43:01
封顶
-
-2@ 2008-09-21 13:57:53
地下室
-
-2@ 2008-09-21 13:54:35
地板
-
-2@ 2008-09-21 08:53:26
divano
-
-3@ 2017-06-21 17:34:04
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>using namespace std;
int dis(const char &a,const char &b){
return abs(a-b)<13?abs(a-b):26-abs(a-b);
}int main(){
string stra,strb,strc;
int n;
cin>>n;
cin>>stra>>strb>>strc;
if(dis(stra[0],strc[n-1])==dis(strb[0],strc[n-1])){
for(int i=n-1;i>=0;--i)cout<<strc[i];
}
else if(dis(stra[0],strb[n-1])==dis(strc[0],strb[n-1])){
for(int i=n-1;i>=0;--i)cout<<strb[i];
}
else if(dis(strc[0],stra[n-1])==dis(strb[0],stra[n-1])){
for(int i=n-1;i>=0;--i)cout<<stra[i];
}
//system("pause");
return 0;
} -
-4@ 2016-07-15 10:55:46
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh'' hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh''hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"