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. linux- svn服务器

    环境:centos6.5 安装 centos 6.5默认安装了svn server, 这里直接使用.如果没有的话,使用yum -y install subversion安装 创建版本库 3.1 创建s ...

  2. javascript一些常用操作

    一:验证日期 1:日期必须满足yyyy-MM-dd格式 2:日期必须是合法的日期,如2016-02-30就是不存在 //验证就诊日期 function checkVisitDate(date){ va ...

  3. [未完成]关于Eclipse4RCP书中内容总结

    原文地址http://www.vogella.com/tutorials/EclipseRCP/article.html Table of Contents 1. Eclipse 4 1.1. Wha ...

  4. 关于JDK中的集合总结(一)

    静态方法只能继承,不能重写(Override). StringBufffer,数组,对象 都是容器. 加入数据,“zhangsan” true ,67, 三个数据数据类型不同,不能用数组作为集合,只能 ...

  5. python学习day4--python基础--字典

    字典的常用操作: #字典天然去重,key唯一,如果key相同,只能打印出一个 id_db={ 220456789852963741:{ 'name':"alex", 'age':3 ...

  6. fuse挂载hdfs目录到linux本地

    1,安装fuse yum -y install hadoop-hdfs-fuse 2.修改环境变量 vi /etc/profile 增加如下配置: JAVA_HOME=/usr/jdk64/jdk1. ...

  7. visual studio 2015预览版系统需求

    visual studio 2015预览版的系统需求跟visual studio 2013的一样. 支持visual studio 2015 preview的操作系统:Windows 8.1(x86 ...

  8. 理解CPU内存管理

    概述:从设计层面理解CPU的内存模式,包括段式内存管理.页式内存管理以及虚拟化扩展内存管理.实际上,硬件支持与软件实现从来就不是能分开讲的,比如,Intel CPU架构师在选择CPU的硬件特性时,必然 ...

  9. Redis配置中文翻译,3.2.1版

    大部分常见设置都翻译了,还有一些是从网上复制的(懒) # Redis configuration file example. ## Redis配置文件示例 # # Note that in order ...

  10. Codevs 1158 尼克的任务

    1158 尼克的任务 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 尼克每天上班之前都连接上英特网,接收他的上司发来的邮件,这些邮 ...