1092. To Buy or Not to Buy
来源:互联网 发布:五金重量计算软件 编辑:程序博客网 时间:2024/04/18 14:34
题意:
商家只卖第一串
买家是第二串
问买家需要的珠子在第一串中满不满足。若满足,看看多买了多少珠子。否则看看缺了哪些
思路:
太简单,哈希表都不需要用,直接用数组
#include<cstdio>#include<algorithm>#include<cstring>#include<iostream>#include<stack>#include<vector>#include<queue>#include<string>#include<map>using namespace std;#define INF 99999999#define M 700int main(){string s1,s2;int hash[1000];int moren=0,lessn=0;memset(hash,0,sizeof(hash));int i,j;cin>>s1;for(i=0;i<s1.length();i++){hash[ s1[i] ]++;}cin>>s2;for(i=0;i<s2.length();i++){if(hash[ s2[i] ]==0){lessn++;}else hash[s2[i]]--;}if(lessn ==0){printf("Yes %d\n",s1.length() - s2.length());}elseprintf("No %d\n",lessn);return 0;}
阅读全文
0 0
- 1092.To Buy or Not to Buy
- 1092. To Buy or Not to Buy
- 1092. To Buy or Not to Buy
- 1092. To Buy or Not to Buy
- 1092. To Buy or Not to Buy
- 1092. To Buy or Not to Buy
- 1004. To Buy or Not to Buy
- 1004. To Buy or Not to Buy
- 1092. To Buy or Not to Buy (20)
- PAT A 1092. To Buy or Not to Buy (20)
- PAT 1092. To Buy or Not to Buy
- 1092. To Buy or Not to Buy (20)
- PAT 1092. To Buy or Not to Buy (20)
- pat 1092. To Buy or Not to Buy (20)
- PAT 1092. To Buy or Not to Buy(STL)
- 1092. To Buy or Not to Buy (20)
- 1092. To Buy or Not to Buy (20)
- PAT 1092. To Buy or Not to Buy (20)
- PRAGMA AUTONOMOUS_TRANSACTION(自治事务)【整理】
- When executing step "Build Android APK"解决方案
- android跳转到系统应用的相关API
- SpringBoot整合模板引擎Thymeleaf
- AIDL不同APP间调用service出现Service Intent must be explicit 解决方案
- 1092. To Buy or Not to Buy
- 文章标题
- 阿里云服务器(windows server2008)下安装SVN
- ST_Curve专业曲线绘制控件
- RR报文解析(三)利用LSR, DLSR计算RTT
- TortoiseSVN 出现unable to connect to a repository at url 由于目标计算机积极拒绝
- iOS 画图框架摘抄
- bwareaopen opencv实现
- Tomcat源码分析-初始化流程