String Subtraction
Given two strings S1 and S2, S = S1 - S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task is simply to calculate S1 - S2 for any given strings. However, it might not be that simple to do it fast.
Input Specification:
Each input file contains one test case. Each case consists of two lines which gives S1 and S2, respectively. The string lengths of both strings are no more than 104. It is guaranteed that all the characters are visible ASCII codes and white space, and a new line character signals the end of a string.
Output Specification:
For each test case, print S1 - S2 in one line.
Sample Input:
They are students.
aeiou
Sample Output:
Thy r stdnts.
//主要是时限,所以该想办法用Hash。
#include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
string ss1,ss2;
int i;
while(getline(cin,ss1))
{
getline(cin,ss2);
map<char,bool> mm;
for(i=0;i<ss1.length();i++)
mm[ss1[i]]=true;
for(i=0;i<ss2.length();i++)
mm[ss2[i]]=false;
for(i=0;i<ss1.length();i++)
if(mm[ss1[i]])
cout<<ss1[i];
cout<<endl;
}
return 0;
}
String Subtraction的更多相关文章
- PAT 解题报告 1050. String Subtraction (20)
1050. String Subtraction (20) Given two strings S1 and S2, S = S1 - S2 is defined to be the remainin ...
- PAT 1050 String Subtraction
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be t ...
- 1050 String Subtraction (20 分)
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be the ...
- pat1050. String Subtraction (20)
1050. String Subtraction (20) 时间限制 10 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Giv ...
- pat 1050 String Subtraction(20 分)
1050 String Subtraction(20 分) Given two strings S1 and S2, S=S1−S2 is defined to be the ...
- PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)
1050 String Subtraction (20 分) Given two strings S1 and S2, S=S1−S2 is defined to be t ...
- PAT_A1050#String Subtraction
Source: PAT A1050 String Subtraction (20 分) Description: Given two strings S1 and S2, S=S1− ...
- PAT甲级——1050 String Subtraction
1050 String Subtraction Given two strings S1 and S2, S=S1−S2 is defined to be the remain ...
- 1050. String Subtraction (20)
this problem is from PAT, which website is http://pat.zju.edu.cn/contests/pat-a-practise/1050. firs ...
随机推荐
- Android(java)学习笔记207:开源项目使用之gif view
1. 由于android没有自带的gif动画,我在Android(java)学习笔记198:Android下的帧动画(Drawable Animation) 播客中提到可以使用AnimationVie ...
- 【AR】增强现实安卓编程 - Vuforia SDK 的安装和使用 (Android Studio)
Vuforia是个强大的AR平台.使用Vuforia API 可以实现物体识别,图片追踪,柱型追踪,多对象追踪,自定义目标追踪,云识别,文字识别,帧标识和虚拟按钮等功能. 它支持Android, iO ...
- Mac 10.9 自带apache2虚拟目录设置
花了好几天时间做这个事,终于成功,把正确的做法记录一下. 如果是第一次使用apache,可以先执行sudo apachectl start,然后在浏览器里打开http://localhost看看效果, ...
- hdu 4585 set应用
#include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #i ...
- hdu 2196 树形dp
思路:先求以1为根时,每个节点到子节点的最大长度.然后再次从1进入进行更新. #include<iostream> #include<cstring> #include< ...
- hdu 4630 树状数组
思路:这题的处理方式和hdu4358有点像.我们用一个pre[x]表示约数x的倍数上次出现的位置,将查询按区间的右节点升序排序.num[i]的约数为j,如果pre[j]为0,就将pre[j]置为i;否 ...
- SQL表连接查询
SQL表连接查询(inner join.full join.left join.right join) 表的数据有: 一.内连接-inner jion : 最常见的连接查询可能是这样,查出学生的名字和 ...
- Android 中的 Service 全面总结 (转)
原文地址:http://www.cnblogs.com/newcj/archive/2011/05/30/2061370.html 1.Service的种类 按运行地点分类: 类别 区别 优点 ...
- Could not load the "defaultimg" image referenced from a nib in the bundle with identifier "com.abc"
出现这个错误提示,是因为在xib中使用了.jpg格式的图片,在图片名称后面加上.jpg即可;
- js(jQuery)获取时间搜集
获取JavaScript 的时间使用内置的Date函数完成 var mydate = new Date(); mydate.getYear(); //获取当前年份(2位) mydate.getFull ...