http://noi.openjudge.cn/ch0107/03/
"""
1.7编程基础之字符串 03 基因相关性
http://noi.openjudge.cn/ch0107/03/
"""
ans=0
n = float(input())
#a,b = list(map(str,input().split()))
a=input()
b=input()
#print(len(a))
for i in range(0,len(a)):
if a[i] == b[i]:
ans += 1
bj=ans/len(a)
if bj>=n:
print("yes")
else:
print("no")
C++代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
char a[501],b[501];
double as;
//cin>>as;
scanf("%lf",&as);
scanf("%s%s",a,b);
//gets(a);
//gets(b);
int len,sum=0;
len=strlen(a);
for(int i=0;i<len;i++)
{
if(a[i]==b[i])
{
sum++;
}
}
double bj;
bj=sum*1.0/len;
if(bj>=as)
{
cout<<"yes";
}
else
{
cout<<"no";
}
return 0;
}