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的更多相关文章

  1. PAT 解题报告 1050. String Subtraction (20)

    1050. String Subtraction (20) Given two strings S1 and S2, S = S1 - S2 is defined to be the remainin ...

  2. PAT 1050 String Subtraction

    1050 String Subtraction (20 分)   Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be t ...

  3. 1050 String Subtraction (20 分)

    1050 String Subtraction (20 分) Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the ...

  4. pat1050. String Subtraction (20)

    1050. String Subtraction (20) 时间限制 10 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue Giv ...

  5. pat 1050 String Subtraction(20 分)

    1050 String Subtraction(20 分) Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the ...

  6. PAT 甲级 1050 String Subtraction (20 分) (简单送分,getline(cin,s)的使用)

    1050 String Subtraction (20 分)   Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be t ...

  7. PAT_A1050#String Subtraction

    Source: PAT A1050 String Subtraction (20 分) Description: Given two strings S​1​​ and S​2​​, S=S​1​​− ...

  8. PAT甲级——1050 String Subtraction

    1050 String Subtraction Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remain ...

  9. 1050. String Subtraction (20)

    this problem  is from PAT, which website is http://pat.zju.edu.cn/contests/pat-a-practise/1050. firs ...

随机推荐

  1. IJKMediaFramework第三方库的使用

    大多数做直播的时候使用 FFMpeg.  IJKMediaFramework也是基于FFMpeg封装 使用起来比较简单,个人觉得如果有能力可以使用 FFMpeg , 使用 FFMpeg对 内存的占用比 ...

  2. 给jdk写注释系列之jdk1.6容器(3)-Iterator设计模式

    前面讲了两种List,一种基于数组实现的ArrayList,一种基于链表实现的LinkedList,这两种list是我们工作中最常用到的List容器.当然数组和链表也是两种常见的基本数据结构,其他基本 ...

  3. 网络编辑器插件ckeditor+ckfinder配置

    原帖地址 另外一个 去掉编辑器的下边栏 在config.js中加入: config.removePlugins = 'elementspath'; config.resize_enabled = fa ...

  4. this及其作用域(函数外部this变量的调用)

    众所周知的一件麻烦事是函数外部的this变量都不可见,但是我们在编写使用局部函数的方法时,却又很可能需要在某一时刻从内部函数访问this变量. 这种情况下可以通过在this变量中存储一个需要的信息(例 ...

  5. HTML5新特性之WebNotifications

    Web Notifications是HTML5中一个令人欣喜的新特性,它支持开发者配置和显示桌面通知,为用户提供更好的体验,最令人称赞的是,即使用户忙于其他工作时也可以收到来自页面的消息通知,例如一个 ...

  6. error LNK2005: DDX_Control 已经在 uafxcwd.lib(wincore2.obj) 中定义

    编译错误提示: 1>afxnmcdd.lib(wincore2.obj) : error LNK2005: "void __stdcall DDX_Control(classCData ...

  7. java SimpleDateFormat非线程安全测试

    public class MyThread extends Thread { private SimpleDateFormat sdf; private String dateString; publ ...

  8. FreeMarker-Built-ins for strings

    http://freemarker.org/docs/ref_builtins_string.html Page Contents boolean cap_first capitalize chop_ ...

  9. hibernate的运行流程

    首先了解什么是对象关系映射,ORM(Object/Relationship Mapping):对象关系映射.对象关系映射是一种为了解决面向对象与关系数据库存在的互不匹配的现象的技术.是通过使用描述对象 ...

  10. 添加线标注ILineElement

    private void AddLineElement(IPolyline polyline) { try { IPolyline pPolyline = polyline; IRgbColor pL ...