zoukankan      html  css  js  c++  java
  • SDUT 3923

    Description

    snow 是个热爱打字的家伙,每次敲出更快的速度都会让他很开心。现在,他拿到一篇新的打字文章,已知这篇文章只有 26 个小写英文字母,给出 snow 打出这 26 个英文字母分别需要多少时间 (s),问 snow 打完这篇文章获得的 kpm(打正确的字数/所花的分钟数)最大为多少?

    注意 snow 可能会打错一些字哦。打错的必定是文章里面存在的。

    Input

    多组输入。

    对于每组数据,首先输入 26 个整数,分别表示打出 a, b, c, ..., z 这 26 个字母需要的时间(保证是 int 范围内的正整数),然后给出一个字符串,长度不超过 1000,保证只包含小写英文字母。

    Output

    对于每组数据,输出一行,表示最大的 kpm,保留 2 位小数。

    Sample Input

    1 2 2 1 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
    abcd
    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
    abcd

    Sample Output

    40.00
    25.71

    不知道打错哪些字会使kpm最高....
    要么是打错零个,要么是打错一个,要么是打错三个......
    如果需要打错字的话,肯定是将耗时多的字打错,会提高kpm,所以从后向前遍历一遍就好了。
    还需要注意一点,前缀和数组的应用。

     1 #include<stdio.h>
     2 #include<stdlib.h>
     3 #include<string.h>
     4 #include<math.h>
     5 #include<algorithm>
     6 #include<queue>
     7 #include<stack>
     8 #include<deque>
     9 #include<iostream>
    10 using namespace std;
    11 typedef long long  LL;
    12 struct cha
    13 {
    14     char c;
    15     int time;
    16 } cha[1009];
    17 int con[200];
    18 char day[1009];
    19 bool cmp(struct cha a,struct cha b)
    20 {
    21     if(a.time==b.time)
    22         return a.c<b.c;
    23     return a.time<b.time;
    24 }
    25 int main()
    26 {
    27     int i,p,j;
    28     char mid;
    29     double min1,x;
    30     while(scanf("%d",&con['a'])!=EOF)
    31     {
    32         for(i='b'; i<='z'; i++)
    33             scanf("%d",&con[i]);
    34         p=-1;
    35         getchar();
    36         gets(day);
    37         for(i=0; i<=1008; i++)
    38         {
    39             if(day[i]==0)
    40                 break;
    41             else
    42             {
    43                 cha[++p].c=day[i];
    44                 cha[p].time=con[day[i]];
    45             }
    46         }
    47         sort(cha,cha+p+1,cmp);
    48 
    49         for(i=0; i<=p; i++)
    50             cha[i].time+=cha[i-1].time;
    51 
    52         min1=((double)(p+1)/cha[p].time)*60;
    53         for(i=p-1; i>=0; i--)
    54         {
    55             x=(double)(i+1)/(cha[i].time+(cha[0].time*(p-i)))*60;
    56             if(x>min1)
    57                 min1=x;
    58         }
    59         printf("%.2lf
    ",min1);
    60     }
    61     return 0;
    62 
    63 }
    View Code
  • 相关阅读:
    java中的数组长度的计算
    用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。C++实现
    c++中计算数组的长度。以及c++中向量的长度的计算的方式。
    3.mouseenter和mouseover事件的区别
    0.jQuery选择器
    2.点击隐藏盒子
    1.jQuery入口函数
    jquery选项卡效果
    %你考试2020.1
    二十七、rsync同步工具
  • 原文地址:https://www.cnblogs.com/daybreaking/p/9351330.html
Copyright © 2011-2022 走看看