店長(zhǎng)推薦Ⅱ
Time Limit: 1000 MS Memory Limit: 65536 K
Total Submit: 97(31 users) Total Accepted: 28(24 users) Special Judge: No
Description

想必大家已經(jīng)領(lǐng)略了店長(zhǎng)的調(diào)皮,自從店長(zhǎng)知道了vagaa之后就一直沉迷期中不能自拔,教主看到后很是傷心,玩物喪志啊!于是教主教店長(zhǎng)了一個(gè)vagaa的新用法,資源搜索功能。輸入一些關(guān)鍵詞后可以搜索出相關(guān)共享的好資源,店長(zhǎng)得知后又是欣喜若狂。同時(shí),教主又發(fā)明一個(gè)游戲,是上次的升級(jí)版,這次給出一些由字母和數(shù)字的玩具的同時(shí),關(guān)鍵字不再是vagaa了,需要自己給出.看最后能組成多少個(gè)關(guān)鍵字。

Input

每行輸入一個(gè)字符串由小寫(xiě)字母和數(shù)字組成,每個(gè)字符代表一個(gè)玩具, 緊接著輸入一個(gè)關(guān)鍵字,同樣由字母和數(shù)字組組成,字符串長(zhǎng)度0<n<=10000,關(guān)鍵字長(zhǎng)度0<m<=200

處理到文件結(jié)束

Output

輸出能夠組成關(guān)鍵字的數(shù)量

按照樣例輸出格式輸出并換行.

Sample Input

vagaadsfaagav  ga
asgvasdfzxcades  dea

Sample Output

Case 1: 2
Case 2: 1

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;
}

 


文章來(lái)源:http://www.cnblogs.com/kuangbin/archive/2012/02/27/2370325.html