跳到正文

题解

题解:P11137 [APC001] B - Checker

zhao__sd约 2 分钟
原文
文章信息与版本

文章信息

发布
2024年10月2日
收录
2025年12月12日
更新
2026年11月21日
篇幅
约 2 分钟
题目
P11137

版本

  1. v1当前

水题没啥好说的

C++
#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;  
}
//求一遍过,求求了 
原文
存档评论2 条抓取于