close

題目連結:  https://onlinejudge.org/external/113/11340.pdf

題目大意: 給一些字元,並給字元分數,問文章內總分幾分

思路:  array or map. 直接紀錄

代碼:  

#include <bits/stdc++.h>
using namespace std;

int main()
{
    //freopen("11340.txt", "r", stdin);
    int n, k;
    string s;
    cin >> n;
    while(n--){
        cin >> k;
        map<char, int> mp;
        for(int i = 0; i < k; ++i){
            char c; int v;
            cin >> c >> v;
            mp[c] = v;
        }
        cin >> k;
        cin.ignore();
        int tot = 0;
        for(int i = 0; i < k; ++i){
            getline(cin, s);
            for(const auto& c: s){
                tot += mp[c];
            }
        }
        printf("%d.%02d$\n", tot/100, tot%100);
    }
    return 0;
}

arrow
arrow
    創作者介紹
    創作者 尾玉 的頭像
    尾玉

    louisfghbvc的部落格

    尾玉 發表在 痞客邦 留言(0) 人氣()