立志用最少的代码做最高效的表达


PAT甲级最优题解——>传送门


Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking all the characters in S​2​​ from S​1​​. Your task is simply to calculate S​1​​−S​2​​ 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 S​1​​ and S​2​​, respectively. The string lengths of both strings are no more than 10​4​​. 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 S​1​​−S​2​​ in one line.

Sample Input:
They are students.
aeiou

Sample Output:
Thy r stdnts.


查询表算法。


#include<bits/stdc++.h>
using namespace std;
int a[300];
int main() {string s1, s2; getline(cin, s1);  getline(cin, s2);for(auto i : s2) a[i]++;for(auto i : s1) if(a[i] == 0) cout << i;return 0;
}

耗时:


求赞哦~ (✪ω✪)

1050 String Subtraction (20 分)_10行代码AC相关推荐

  1. 【简便代码】1063 计算谱半径 (20分)_10行代码AC

    立志用更少的代码做更高效的表达 Pat乙级最优化代码+题解+分析汇总-->传送门 在数学中,矩阵的"谱半径"是指其特征值的模集合的上确界.换言之,对于给定的 n 个复数空间的 ...

  2. PAT甲级 -- 1050 String Subtraction (20 分)

    Given two strings S​1​​ and S​2​​, S=S​1​​−S​2​​ is defined to be the remaining string after taking ...

  3. 1081 Rational Sum (20 分)_22行代码AC

    立志用最少的代码做最高效的表达 PAT甲级最优题解-->传送门 Given N rational numbers in the form numerator/denominator, you a ...

  4. 【PAT甲级 删除字符串中的指定字符】1050 String Subtraction (20 分) C++

    题目 删除字符串中的另一个字符串包含的所有字符. 可以通过判断两个字符串是否为空,来稍微优化一下运行速度 题解C++ #include<iostream> #include<stri ...

  5. C++ PAT甲级 1050 String Subtraction (20分)

    Given two strings S​1 and S​2, S=S1−S​2is defined to be the remaining string aftertaking all the cha ...

  6. 【PAT (Advanced Level) Practice】1050 String Subtraction (20 分)

    C/C++中整型数组的下标类型不一定为整型,C C++语言下数组性质与散列有些类似,即散列中的键值对:下标即为关键码,关键码通过散列函数映射得到元素即为值 下标可以为整型,也可以为字符型,简单案例如下 ...

  7. 1094 谷歌的招聘 (20分)_25行代码AC

    立志用最少的代码做更高效的表达 PAT乙级最优题解-->传送门 2004 年 7 月,谷歌在硅谷的 101 号公路边竖立了一块巨大的广告牌(如下图)用于招聘.内容超级简单,就是一个以 .com ...

  8. 【测试点分析】1067 试密码 (20分)_20行代码AC

    立志用更少的代码做更高效的表达 Pat乙级最优化代码+题解+分析汇总-->传送门 当你试图登录某个系统却忘了密码时,系统一般只会允许你尝试有限多次,当超出允许次数时,账号就会被锁死.本题就请你实 ...

  9. 1073 多选题常见计分法 (20 分)_66行代码AC

    立志用最少的代码做最高效的表达 PAT乙级最优题解-->传送门 批改多选题是比较麻烦的事情,有很多不同的计分方法.有一种最常见的计分方法是:如果考生选择了部分正确选项,并且没有选择任何错误选项, ...

最新文章

  1. xshell virt-manager RuntimeError: could not open display
  2. 使用docker搭建一个elasticsearch(5.4)的基础环境
  3. 【408预推免复习】操作系统之虚拟存储器
  4. 避免重蹈欧美“超级电厂”覆辙 瑞星全力保障国内电力行业信息安全
  5. boost::smart_ptr模块collector相关的测试程序
  6. 中职计算机专业英语说课稿,高职高专英语说课稿
  7. c++ 删除二叉树的子树_平衡二叉树
  8. Linux文件锁学习-flock, lockf, fcntl
  9. MATLAB信号处理之常用信号的表示(2)
  10. html 图片 按钮,css按钮背景图片如何实现?(代码实例)
  11. CentOS7.0下安装PHP5.6.30服务
  12. VM下安装ubuntu教程
  13. 为什么要使用Memcached
  14. ECSHOP问题总结
  15. Vue element table按钮实现当行expand详情(右箭头)
  16. 孩子给产品经理的一堂课
  17. linux监控工具gotop
  18. xargs -i参数详解
  19. Spring data报错:Inferred type 'S' for type parameter 'S' is not within its bound;
  20. python流水灯简单程序_简单流水灯的实现程序

热门文章

  1. 【实战分享】漫谈 gRPC的选型
  2. Python中hasattr() getattr() setattr() 函数的使用
  3. SQL 学习最强刷题网站!
  4. SQL 查询总是先执行SELECT语句吗?
  5. RabbitMQ之镜像队列
  6. Go channel 的妙用
  7. HTTP和HTTPS总结
  8. 揭秘北京2022冬奥会背后的技术
  9. 【今晚七点半】:爱奇艺DRM探索之路
  10. 华为云RTC服务架构及应用实践