这是我的第一个文章,给看一下我自己的c++题目吧,哈哈!

题目背景

急性白血病是一种极为凶险的疾病,也被称之为血癌,目前临床上常采用骨髓移植的方法来更新造血干细胞$(stem cells)$.

题目描述

造血干细胞在移植前需要配型,也就是比对$HLA$(人类白细胞抗原),我们必须保证移植患者与捐献者的$HLA$有至少$50%$(字符串长度一半四舍五入)以上的相似,==HLA一般是一串字母,在这里,我们简化成n位字母.==

输入输出格式

输入格式

首先一个n,表示字符串长度
两个长度为n的字符串,==分别表示患者和捐献者==

输出格式

是否可以进行移植(Yes or No)

输入输出样例

1
2
3
6
AGGCTA
AGCTAA
1
Yes

数据规模与约定

对于输入数据,有 0<n<=10

AC代码:(自己写的)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include<iostream>
#include<cmath>
using namespace std;
int main(){
int n,standard,cnt=0;
string pre,xian;
cin>>n>>pre>>xian;
int pre_length = pre.length(),xian_length = xian.length();
standard = round(n/2.0);
for(int i=0;i<pre_length;i++){
if(pre[i]==xian[i]){
cnt++;
}
}
if(cnt >=standard){
cout<<"Yes";
}
else{
cout<<"No";
}


return 0;
}

题目地址

https://hydro.ac/d/wangbin123456/p/QY0010