商家只卖第一串 买家是第二串 问买家需要的珠子在第一串中满不满足。若满足,看看多买了多少珠子。否则看看缺了哪些 思路: 太简单,哈希表都不需要用,直接用数组 #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #include<stack> #include<vector> #include<queue> #include<string>...
1092. To Buy or Not to Buy (20)-map 给出两个字符串,判断第二个字符串中的字符是否都出现在第一个中。 是,则输出Yes,以及多余的字符的个数。 否,则输出No,以及缺失的个数。 View Code
string a,b; int main() { cin>>a>>b; for(auto t:a) mpa[t]++; for(auto t:b) mpb[t]++; int buy=0,miss=0; for(auto t:mpb) { if(t.se > mpa[t.fi]) miss+=t.se-mpa[t.fi]; } if(!miss) cout<<"Yes"<<' '<<a.size()-b.size()<<endl; else cout<<"No"<<' ...
很简单的散列。 #include<iostream>#include<cstdio>#include<string>usingnamespacestd;intmain(){#if ONLINE_JUDGE#elsefreopen("input.txt","r",stdin);#endifintcodes[129]={0};stringowner,eva;cin>>owner>>eva;for(inti=0;i<eva.size();i++){codes[eva[i]]++;}for(inti=0;i<owner.size();...
1092 To Buy or Not to Buy (20分) Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner of the shop would only sell the strings in whole pieces. Hence Eva must...
pieces. Hence Eva must check whether a string in the shop contains all the beads she needs. She now comes to you for help: if the answer isYes, please tell her the number of extra beads she has to buy; or if the answer isNo, please tell her the number of beads missing from the...
PAT-A 真题 - 1092 To Buy or Not to Buy Eva would like to make a string of beads with her favorite colors so she went to a small shop to buy some beads. There were many colorful strings of beads. However the owner of the shop would only sell the strings in whole pieces. Hence ...
#include<iostream>#include<string>#include<cstring>usingnamespacestd;string s1,s2;inthashtable[256];intmain(){getline(cin,s1);getline(cin,s2);intmis=0;for(inti=0;i<s1.length();i++)hashtable[s1[i]]++;for(inti=0;i<s2.length();i++){if(hashtable[s2[i]])hashtable[s2[i]]--;...
1092. To Buy or Not to Buy (20) simple 简介:#include using namespace std;int main(int argc, const char * argv[]) { // insert code here. #include<iostream>usingnamespacestd;intmain(intargc,constchar* argv[]){// insert code here...string s0, s;...
The MAX1090/MAX1092 low-power, 10-bit analog-to-digital converters (ADCs) feature a successive-approximation ADC, automatic power-down, fast wake-up (2µs), an on-chip clock, +2.5V internal reference, and a high-speed, byte-wide parallel interface. The devices operate with a single +...