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