题解:P11137 [APC001] B - Checker

· · 题解

P11137 [APC001] B - Checker题解

对于每个字符串,依次枚举每个字符,如果字符相同就把相同字符数量 +1,如果相同字符数量 \ge\lceil\frac{k}{2}\rceil,则重题数 +1。最后输出即可。

代码:

#include<bits/stdc++.h>
using namespace std;
int n,a;
string s,t;
int main(){
    cin>>n>>s;
    while(n--){
        cin>>t;
        int c=0;
        for(int i=0;i<s.size();i++)if(s[i]==t[i])c++;
        if(c>=(s.size()+1)/2)a++;
    }
    cout<<a<<'\n'<<(!a?"Good job!":"Make persistent efforts.");
    return 0;
}