HDU 4147 KFC -Z+W

版权声明:欢迎提问:3079238667@qq.com https://blog.csdn.net/include_heqile/article/details/79981125

水题:http://acm.hdu.edu.cn/showproblem.php?pid=4147

#include<stdio.h>
#include<string.h>

int main() {
    int n, B, D, f, F;
    while(~scanf("%d%d%d%d%d", &n, &B, &D, &f, &F)) {
        char str[1001];
        int num[1001];
        memset(str, '\0', sizeof(str));
        memset(num, 0, sizeof(num));
        int a1 = B+D+f;
        int a2 = 2*B+2*D+F;
        int a3 = 3*B+3*D+2*F;
        int minx = 1000000;
        int s1, s2, s3;
        int sum = 0;
        for(int i = 0; i < n; i++) {
            scanf("%s", str);
            int sum1 = 0;
            int sum2 = 0;
            int sum3 = 0;
            for(int j = 0; j < strlen(str); j++) {
                if(str[j] == 'A')
                    sum1+=1;
                else if(str[j] == 'B')
                    sum2+=1;
                else if(str[j] == 'C')
                    sum3+=1;
            }
            sum = sum1*1+sum2*2+sum3*3;
            if(sum < minx) {
                minx = sum;
                s1 = sum1;s2 = sum2; s3 = sum3;
            }
        }
        printf("%d\n", s1*a1+s2*a2+s3*a3);
    }
    return 0;
}
阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页