Message Flood
来源:互联网 发布:win7打开23端口 编辑:程序博客网 时间:2024/06/07 07:16
Think:
没怎么看题意, 看输入输出 感觉就是 输入 几个名字, 然后 再输入 m个名字 计算 没出现名字的 个数;
思路:
用 SET《string》 来存储, 第二次输入时 判断人名是否出现, 出现过的话 计数器 +1 &&同时 消去人名。
坑点:
贼坑!!WA了好多发, 不区分大小写!!!! 所以 就要 全部转为大写或者 全部转为小写~~~~;
tolower()的 作用就是将小写字母 转换为大写字母。
toupper()的 作用就是将大写字母 转换为小写字母。
Problem Description
Well, how do you feel about mobile phone? Your answer would probably be something like that “It’s so convenient and benefits people a lot”. However, If you ask Merlin this question on the New Year’s Eve, he will definitely answer “What a trouble! I have to keep my fingers moving on the phone the whole night, because I have so many greeting message to send!” Yes, Merlin has such a long name list of his friends, and he would like to send a greeting message to each of them. What’s worse, Merlin has another long name list of senders that have sent message to him, and he doesn’t want to send another message to bother them Merlin is so polite that he always replies each message he receives immediately). So, before he begins to send message, he needs to figure to how many friends are left to be sent. Please write a program to help him. Here is something that you should note. First, Merlin’s friend list is not ordered, and each name is alphabetic strings and case insensitive. These names are guaranteed to be not duplicated. Second, some senders may send more than one message to Merlin, therefore the sender list may be duplicated. Third, Merlin is known by so many people, that’s why some message senders are even not included in his friend list.
Input
There are multiple test cases. In each case, at the first line there are two numbers n and m (1<=n,m<=20000), which is the number of friends and the number of messages he has received. And then there are n lines of alphabetic strings(the length of each will be less than 10), indicating the names of Merlin’s friends, one per line. After that there are m lines of alphabetic strings, which are the names of message senders. The input is terminated by n=0.
Output
For each case, print one integer in one line which indicates the number of left friends he must send.
Example Input
5 3
Inkfish
Henry
Carp
Max
Jericho
Carp
Max
Carp
0
Example Output
3
#include<bits/stdc++.h>using namespace std;int main(){ int i; set<string>s; string key; int n, m, j; while(cin >> n) { if (n == 0) return 0; cin >> m; int cnt = 0; s.clear(); for (i = 0; i < n; i ++) { cin >> key; for (j = 0;j < key.size();j ++) { key[j] = tolower(key[j]); } s.insert(key); } while(m --) { cin >> key; for (j = 0;j < key.size();j ++) { key[j] = tolower(key[j]); } if (s.count(key) != 0) { cnt = cnt + 1; s.erase(key); } } cout << n - cnt << endl; }}
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Message Flood
- Tensorflow的padding操作
- iOS 成员变量,实例变量,属性变量的区别,联系
- 算法 排序算法之选择排序--直接选择排序和堆排序
- c++中如何实现一个不能被继承的类
- Illegal access: this web application instance has been stopped already .【心里的疑惑化解了】
- Message Flood
- 现在社会发展关键词
- 第十四周:[LeetCode]10. Regular Expression Matching
- servlet生命周期
- 用Python爬取某吧的美图
- java如何解析传来的xml字符串
- 往电子书里面挂书签
- C语言学习之路-由浅入深(快速掌握c基础)
- 2017浙工大之江学院校赛 E 折半搜索+二分