牛客网 牛客小白月赛2 G.文

 

G.文

链接:https://www.nowcoder.com/acm/contest/86/G

这个题wa了一发,有点智障,浮点数,式子里面要*1.0,忘了,然后wa了,改了就过了(脑子有坑)

 

代码:

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<cmath>
 5 #include<cstdlib>
 6 #include<algorithm>
 7 #include<queue>
 8 #include<vector>
 9 #include<stack>
10 using namespace std;
11 typedef long long ll;
12 const int maxn=1e5+10;
13 const double eps=1e-7;
14  
15 struct node{
16     string name; 17 char c[maxn]; 18 int num=0; 19 }a[110]; 20 21 bool cmp(node a,node b){ 22 if(a.num<b.num)return 1; 23 else if(a.num==b.num){ 24 if(a.name<b.name)return 1; 25 else return 0; 26  } 27 else return 0; 28 } 29 char s[maxn]; 30 int main(){ 31 int n,m; 32 cin>>n>>m; 33 for(int i=0;i<n;i++) 34 cin>>s[i]; 35 for(int i=0;i<m;i++){ 36 cin>>a[i].name>>a[i].c; 37 for(int j=0;j<n;j++){ 38 if(a[i].c[j]!=s[j])a[i].num++; 39  } 40  } 41 sort(a,a+m,cmp); 42 cout<<a[0].name<<endl; 43 double score=100*1.0/n*(n-a[0].num); 44 printf("%.2f\n",score); 45 }

 

转载于:https://www.cnblogs.com/ZERO-/p/9729056.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值