【PAT甲级】1050 String Subtraction (20 分)
题意:
输入两个串,长度小于10000,输出第一个串去掉第二个串含有的字符的余串。
trick:
ascii码为0的是NULL,减去'0','a','A',均会导致可能减成负数。
AAAAAccepted code:
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
char s1[],s2[];
int vis[];
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin.getline(s1,);
cin.getline(s2,);
int n=strlen(s1);
int m=strlen(s2);
for(int i=;i<m;++i)
vis[s2[i]-NULL]=;
for(int i=;i<n;++i)
if(!vis[s1[i]-NULL])
cout<<s1[i];
return ;
}
【PAT甲级】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 ...
- PAT练习--1050 String Subtraction (20 分)
题⽬⼤意:给出两个字符串,在第⼀个字符串中删除第⼆个字符串中出现过的所有字符并输出. 这道题的思路:将哈希表里关于字符串s2的所有字符都置为true,再对s1的每个字符进行判断,若Hash[s1[i] ...
- PAT甲级——1050 String Subtraction
1050 String Subtraction Given two strings S1 and S2, S=S1−S2 is defined to be the remain ...
- PAT 甲级 1050 String Subtraction
https://pintia.cn/problem-sets/994805342720868352/problems/994805429018673152 Given two strings S~1~ ...
- PAT Advanced 1050 String Subtraction (20) [Hash散列]
题目 Given two strings S1 and S2, S = S1 – S2 is defined to be the remaining string afer taking all th ...
- 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)
1050. String Subtraction (20) Given two strings S1 and S2, S = S1 - S2 is defined to be the remainin ...
- PAT 甲级 1035 Password (20 分)
1035 Password (20 分) To prepare for PAT, the judge sometimes has to generate random passwords for th ...
随机推荐
- servlet中Request与response使用
服务器根据请求自动创建传入HttpServletRequest对象和HttpServletResponse对象 @Override protected void service(HttpServlet ...
- C语言随笔4:指针数组、数组指针
数组: 1:数组名为地址,表达方法: Int A[10]; A;//数组名表示首地址 &A;//数组名加取地址符,仍然表示首地址 &A[0];//第0个元素的地址,即首地址 数组名是指 ...
- 线性筛-mobius,强大O(n)
首先,你要知道什么是莫比乌斯函数 然后,你要知道什么是积性函数 最后,你最好知道什么是线性筛 莫比乌斯反演 积性函数 线性筛,见上一篇 知道了,就可以愉快的写mobius函数了 由定义: μ(n)= ...
- 09day 命令提示符优化及yum优化
export PS1='\[\e[32;1m\][\u@\h \W]\$ \[\e[0m\]' 设置颜色 内容 结束 export PS1='\[\e[30;1m\][\u@\h \W]\$ \[\e ...
- css全站字体,中文英文不同,粗细统一
@font-face { font-family: vwfont; src: url(/shop-m/public/fonts/VWText-Regular.otf); } @font-face { ...
- redis 基础操作教程
1.linux 安装redis : Linux 下安装 下载地址:http://redis.io/download,下载最新稳定版本. 本教程使用的最新文档版本为 2.8.17,下载并安装: $ wg ...
- linux sftp 和scp 运用
Linux scp命令: Upload to remote :复制本地文件到远程 Part1: Scp -P port local_file remote_user@remote_ip:rem ...
- pyqt5去单选框外包围的矩形框
1.通过QT Designer改变css样式 border:none; 2.通过setStyleSheet("border:none;") Button.setStyleSheet ...
- List 重载添加-add,删除-remove方法,以及获取子集方法
package seday12; import java.util.ArrayList;import java.util.List; /*** @author xingsir* List重载了一对ad ...
- finalize()
本文介绍的是Java里一个内建的概念,Finalizer.你可能对它对数家珍,但也可能从未听闻过,这得看你有没有花时间完整地看过一遍java.lang.Object类了.在java.lang.Obje ...