http://ac.jobdu.com/problem.php?pid=1175
#include <stdio.h>
#include <string.h>
char a[105],b[105];
int count[10]; //统计a中出现牌的个数,1几张,2几张
int main()
{//freopen("D:\\1.txt","r",stdin);
int i,x;
while (scanf("%s%s",a,b)!=EOF)
{
memset(count,0,sizeof(count));
bool success=false;
int lena=strlen(a);
int lenb=strlen(b);
for (i=0;i<lena;i++)
{
x=a[i]-'0'; //牌3
count[x]++; //hash 3的数量++
}
if (lenb<5) //当牌少于5张,那就是几张相同牌
{
x=b[0]-'0'; //得到牌的值,若是4,注意出牌小于5张时,它们一定是相同的
for (i=x+1;i<10;i++) //5~9判断,是否有大于4的至少相同数量的牌
{
if (count[i]>=lenb)
{
success=1;
break;
}
}
}
else
{
int x=b[0]-'0';
for (i=x+1;i<6;i++)
{
if (count[i]>0&&count[i+1]>0&&count[i+2]>0&&count[i+3]>0&&count[i+4]>0)
{
success=1;
break;
}
}
}
if (success)
{
printf("YES\n");
}
else
printf("NO\n");
}
return 0;
}