码迷,mamicode.com
首页 > 其他好文 > 详细

gym-101350M

时间:2017-12-21 23:02:11      阅读:173      评论:0      收藏:0      [点我收藏+]

标签:bsp   log   题意   --   turn   algorithm   ++   can   scanf   

题意:给你一堆货币汇率,再给你一堆货币,算下值多少钱;

思路:直接map搞定;

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<map>
using namespace std;
int main()
{
    int n,c;
    int t;
    char s[1000];
    double ans,temp;
    scanf("%d",&t);
    while(t--)
    {
        map<string,double>money;
        ans=0;
        scanf("%d%d",&c,&n);
        for(int i=0;i<c;i++)
        {
            scanf("%s",s);
            scanf("%lf",&temp);
            money[s]=temp;
        }
        money["JD"]=1;
        for(int i=0;i<n;i++)
        {
            scanf("%lf",&temp);
            scanf("%s",s);
            ans=ans+money[s]*temp;
        }
        printf("%.6lf\n",ans);
    }
    return 0;
}

 

gym-101350M

标签:bsp   log   题意   --   turn   algorithm   ++   can   scanf   

原文地址:http://www.cnblogs.com/huangdao/p/8082669.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!