Friday, June 10, 2016

UVA 11340 solution

Unknown
#include<cstdio>
#include<string.h>
using namespace std;

int main()
{
    int t;
    scanf("%d",&t);
    while (t--)
    {
        int n,m,v[111],total=0;
        char c[111],s[10005];
        scanf("%d",&n);
        for (int i=0;i<n;i++)
        {
            getchar();
            scanf("%c%d",&c[i],&v[i]);
        }
        scanf("%d",&m);
        getchar();
        while (m--)
        {
            gets(s);
            int l=strlen(s);
            for (int j=0;j<n;j++)
                for (int i=0;i<l;i++)
                    if (c[j]==s[i]) total+=v[j];
        }
        double ans=total/100.0;
        printf ("%.2lf$\n",ans );
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,