zoukankan      html  css  js  c++  java
  • 牛客网 牛客小白月赛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
    ",score);
    45 }
  • 相关阅读:
    网络协议 22
    网络协议 21
    网络协议 20
    网络协议 19
    网络协议 18
    网络协议 17
    网络协议 16
    网络协议 15
    网络协议 14
    .net 4.0 中的特性总结(五):并行编程
  • 原文地址:https://www.cnblogs.com/ZERO-/p/9729056.html
Copyright © 2011-2022 走看看