首页 > ACM题库 > HDU-杭电 > HDU 4147-KFC -Z+W[解题报告]HOJ
2015
04-16

HDU 4147-KFC -Z+W[解题报告]HOJ

KFC -Z+W

问题描述 :

Welcome to KFC!
We love KFC, but we hate the looooooooooong queue.
Z is a programmer; he’s got an idea on the queue time computing.
Z chooses the shortest queue at first time.
He wrote a j2me program to predicate the time he have to wait in the queue. Now, he comes to KFC to test his program.
BUT, he ignored some important things to get the precise time.
* People choose different foods
* Time used on foods various
W encountered him just while his wondering on the problem, so he discussed it with HER.
W suggested that they can add variables to this
* A type ,who is looking down on the cell phone novel should come here alone, will call for 1 hamburger, 1 drink and 1 small fries
* B type, two talkative lovers, 1 hamburger and 1 drink for each one and another big fires
* C type, middle aged father/mother looks, brings their child out. 3 hamburgers, 3 drinks and two big friezes.
Generally represent the types usually appear, not the exactly math work.
They reprogram the app on W’s HTC-G1 with bash, run it and go for the fastest queue.

输入:

Input contains multiple test cases, and for each case:
First line: n B D f F, stands for n queues, time for hamburger B, time for Drink D, time for small fries f, time for big Fries F.
The next n lines: the types of each line using ABC characters.
(1<n,B,D,f,F<=100)

输出:

Input contains multiple test cases, and for each case:
First line: n B D f F, stands for n queues, time for hamburger B, time for Drink D, time for small fries f, time for big Fries F.
The next n lines: the types of each line using ABC characters.
(1<n,B,D,f,F<=100)

样例输入:

3 2 2 1 2
ABCCBACBCBAB
CBCBABBCBA
ABC

样例输出:

31

点击打开链接

#include <stdio.h>
#include <string.h>
int main()
{
        int n, B, D, f, F, i, j, time_A, time_B, time_C, time_min;
        int time_sum[100];
        char menu[100];
        while(scanf("%d%d%d%d%d", &n, &B, &D, &f, &F)==5)
        {
                time_A = B + D + f;
                time_B = B + B + D +  D + F;
                time_C = B + B + B + D + D + D +  F + F;
                time_min = -1;
                for(i = 0; i < n; ++i)
                {
                        time_sum[i] = 0;
                        scanf("%s", menu);
                        for(j = 0; menu[j] != '\0'; ++j)
                        {
                                if(menu[j] == 'A')
                                time_sum[i] += time_A;
                                if(menu[j] == 'B')
                                        time_sum[i] += time_B;
                                if(menu[j] == 'C')
                                        time_sum[i] += time_C;
                        }
                        if(time_min == -1 || time_sum[i] < time_min)
                                time_min = time_sum[i];
                }
                printf("%d\n", time_min);
        }
        return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

参考:http://blog.csdn.net/budatuacm/article/details/9878937


  1. for(int i=1; i<=m; i++){
    for(int j=1; j<=n; j++){
    dp = dp [j-1] + 1;
    if(s1.charAt(i-1) == s3.charAt(i+j-1))
    dp = dp[i-1] + 1;
    if(s2.charAt(j-1) == s3.charAt(i+j-1))
    dp = Math.max(dp [j - 1] + 1, dp );
    }
    }
    这里的代码似乎有点问题? dp(i)(j) = dp(i)(j-1) + 1;这个例子System.out.println(ils.isInterleave("aa","dbbca", "aadbbcb"));返回的应该是false