题解:P11137 [APC001] B - Checker
zhao__sd
·
·
题解
水题没啥好说的
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
// 计算两个字符串在相同位置匹配的字符数量
int comp(const string& str1, const string& str2) {
int count = 0;
for (size_t i = 0; i < str1.length(); ++i) {
if (str1[i] == str2[i]) {
++count;
}
}
return count;
}
int main() {
int n;
cin >> n;
string s;
cin >> s;
vector<string> questions(n);
for (int i = 0; i < n; ++i) {
cin >> questions[i];
}
int k = s.length();
int threshold = ceil(k / 2.0);
int ans = 0;
for (const string& question : questions) { //函数比较如果一样就ans++
if (comp(s, question) >= threshold) {
++ans;
}
}
cout << ans << endl;
if (ans == 0) {
cout << "Good job!" << endl;
} else {
cout << "Make persistent efforts." << endl;
}
//水题一道,没啥好说的
return 0;
}
//求一遍过,求求了