POJ2403 Hay Points
题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=2403
#include <map>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int m,n;
map<string, int> dict;
cin >> m >>n;
int i;
string word;
int nValue;
for (i = 0; i < m; ++i)
{
cin >> word >> nValue;
dict[word] = nValue;
}
for (i = 0; i < n; ++i)
{
int sum = 0;
while (cin >> word && word != ".")
{
if (dict.find(word) != dict.end())
{
sum += dict[word];
}
}
cout << sum << endl;
}
return 0;
}
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int m,n;
map<string, int> dict;
cin >> m >>n;
int i;
string word;
int nValue;
for (i = 0; i < m; ++i)
{
cin >> word >> nValue;
dict[word] = nValue;
}
for (i = 0; i < n; ++i)
{
int sum = 0;
while (cin >> word && word != ".")
{
if (dict.find(word) != dict.end())
{
sum += dict[word];
}
}
cout << sum << endl;
}
return 0;
}
作者:洞庭散人
出处:http://phinecos.cnblogs.com/
本博客遵从Creative Commons Attribution 3.0 License,若用于非商业目的,您可以自由转载,但请保留原作者信息和文章链接URL。
posted on 2009-09-12 15:07 Phinecos(洞庭散人) 阅读(655) 评论(0) 编辑 收藏 举报