1050 String Subtraction (20 分)
Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking all the characters in S2from 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.
分析:散列,水题,用map映射比较快
/**
* Copyright(c)
* All rights reserved.
* Author : Mered1th
* Date : 2019-02-25-21.03.43
* Description : A1050
*/
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<unordered_set>
#include<map>
#include<vector>
#include<set>
using namespace std;
int main(){
#ifdef ONLINE_JUDGE
#else
freopen("1.txt", "r", stdin);
#endif
string a,b;
getline(cin,a);
getline(cin,b);
map<char,int> mp;
;i<b.length();i++){
mp[b[i]]++;
}
;i<a.length();i++){
){
printf("%c",a[i]);
}
}
;
}
1050 String Subtraction (20 分)的更多相关文章
- 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 Advanced 1050 String Subtraction (20 分)
Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking ...
- 1050 String Subtraction (20分)
Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking ...
- PAT练习--1050 String Subtraction (20 分)
题⽬⼤意:给出两个字符串,在第⼀个字符串中删除第⼆个字符串中出现过的所有字符并输出. 这道题的思路:将哈希表里关于字符串s2的所有字符都置为true,再对s1的每个字符进行判断,若Hash[s1[i] ...
- 【PAT甲级】1050 String Subtraction (20 分)
题意: 输入两个串,长度小于10000,输出第一个串去掉第二个串含有的字符的余串. trick: ascii码为0的是NULL,减去'0','a','A',均会导致可能减成负数. AAAAAccept ...
- PAT 解题报告 1050. String Subtraction (20)
1050. String Subtraction (20) Given two strings S1 and S2, S = S1 - S2 is defined to be the remainin ...
- 1050. String Subtraction (20)
this problem is from PAT, which website is http://pat.zju.edu.cn/contests/pat-a-practise/1050. firs ...
- PAT (Advanced Level) 1050. String Subtraction (20)
简单题. #include<iostream> #include<cstring> #include<cmath> #include<algorithm> ...
- PAT甲题题解-1050. String Subtraction (20)-水题
#include <iostream> #include <cstdio> #include <string.h> #include <algorithm&g ...
- A1050 String Subtraction (20 分)
一.技术总结 这个是使用了一个bool类型的数组来判断该字符是否应该被输出. 然后就是如果在str2中出现那么就判断为false,被消除不被输出. 遍历str1如果字符位true则输出该字符. 还有需 ...
随机推荐
- JQ延迟对象
延迟对象初识 技术一般水平有限,有什么错的地方,望大家指正. ES6已经实现了延迟对象Promise,但是今天主角是JQ里面的延迟对象,套路其实都是差不多的.下面先看一个比较牵强的例子: <bu ...
- 爬虫从网页中去取的数据中包含 空格
爬虫从网页中爬取的数据中带了一个 这样的空格,使用trim()函数和replace(" ", "")去掉不了,找了一下资料发现,空格有两种一种是从键盘输入的对应 ...
- JavaScript权威指南——跳转语句
前言:JavaScript中有一类语句叫做跳转语句.从名称就可以看出,它使得JavaScript的执行可以从一个位置跳转到另一个位置. return语句让解释器跳出循环体的执行,并提供本次调用的返回值 ...
- iOS 证书 设置指南
点击这里跳转到改链接:http://docs.jpush.cn/pages/viewpage.action?pageId=1343727
- webbench-1.5_hacking
/**************************************************************************** * * webbench-1.5_hacki ...
- STM32 用c语言控制4个LED灯从左向右无限流动
在用c语言写LED流水灯的前提条件是配置好其他环境,这里我就不说环境了, 想让LED灯无限循环时,首先要想到的是无限循环函数,我这里利用的是for函数 无限循环. #include "stm ...
- 控制input只输入数字--- onkeyup="value=value.replace(/[^\d]/g,'')"
☆ <td><input type="text" class="spInput" onkeyup="value=value.repl ...
- BZOJ 1845三角形面积并
题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1845 给定100个三角形,求三角形面积并. 戴神模板太可怕.直接调用函数秒掉.思路 ...
- log4net保存到数据库系列一:WebConfig中配置log4net
园子里面有很多关于log4net保存到数据库的帖子,但是要动手操作还是比较不易,从头开始学习log4net数据库日志 一.WebConfig中配置log4net 二.独立配置文件中配置log4net ...
- JS替换空格回车换行符
JS替换空格回车换行符 str=str.replace(/\r/g," ") str=str.replace(/\n/g,"<br />") 或 ...