题解
2024-06-17 13:05:40
发布于:广东
2阅读
0回复
0点赞
实际上题目就是要我们找给的数据中有哪个数不含D
C++:
#include <iostream>
#include <cstdio>
using namespace std;
int solve(){
int n, ct = 0;
char c;
cin >> n >> c;
string s;
for(int i = 1; i <= n; i++){
cin >> s;
bool flag = 1;
for(int j = 0; s[j] != '\0'; j++){
if(s[j] == c){
flag = 0;
break;
}
}ct += flag;
}return ct;
}
int main(){
int t;
cin >> t;
while(t--){
cout << solve() << endl;
}
return 0;
}
Python:
def solve():
a = input().split()
m = a[1]
a = input().split()
ct = 0
for i in a:
ct += (i.find(m) == -1)
return ct
t = int(input())
while(t):
t -= 1
print(solve())
单测试数据时间复杂度:
这里空空如也
有帮助,赞一个