| 店長推薦Ⅱ | |||||
|
|||||
| Description | |||||
|
想必大家已經領略了店長的調皮,自從店長知道了vagaa之后就一直沉迷期中不能自拔,教主看到后很是傷心,玩物喪志啊!于是教主教店長了一個vagaa的新用法,資源搜索功能。輸入一些關鍵詞后可以搜索出相關共享的好資源,店長得知后又是欣喜若狂。同時,教主又發明一個游戲,是上次的升級版,這次給出一些由字母和數字的玩具的同時,關鍵字不再是vagaa了,需要自己給出.看最后能組成多少個關鍵字。 |
|||||
| Input | |||||
|
每行輸入一個字符串由小寫字母和數字組成,每個字符代表一個玩具, 緊接著輸入一個關鍵字,同樣由字母和數字組組成,字符串長度0<n<=10000,關鍵字長度0<m<=200 處理到文件結束 |
|||||
| Output | |||||
|
輸出能夠組成關鍵字的數量 按照樣例輸出格式輸出并換行. |
|||||
| Sample Input | |||||
|
vagaadsfaagav ga |
|||||
| Sample Output | |||||
|
Case 1: 2 |
|||||
| Author | |||||
| void |
#include<stdio.h>
#include<string.h>
int tt[40],count[40];
char str[10010];
int main()
{
int len,m;
int iCase=0;
while(scanf("%s",&str)!=EOF)
{
iCase++;
len=strlen(str);
memset(tt,0,sizeof(tt));
memset(count,0,sizeof(count));
for(int i=0;i<len;i++)
{
if(str[i]>='0'&&str[i]<='9')
{
m=str[i]-'0'+0;
tt[m]++;
}
else
{
m=str[i]-'a'+10;
tt[m]++;
}
}
scanf("%s",&str);
len=strlen(str);
for(int i=0;i<len;i++)
{
if(str[i]>='0'&&str[i]<='9')
{
m=str[i]-'0'+0;
count[m]++;
}
else
{
m=str[i]-'a'+10;
count[m]++;
}
}
int res=10000;
for(int i=0;i<=9+26;i++)
{
if(count[i]>0)
{
int tmp=tt[i]/count[i];
if(tmp<res) res=tmp;
}
}
printf("Case %d: %d\n",iCase,res);
}
return 0;
}
文章來源:http://www.cnblogs.com/kuangbin/archive/2012/02/27/2370325.html

