竞赛题 忙碌的双11 求大神帮忙

竞赛题 忙碌的双11 求大神帮忙

问题描述:

竞赛题
E 忙碌的双11
Time Limit:1000MS Memory Limit:65535K
题型: 编程题 语言: 无限制
描述
今天是一年一度的双11购物节,人们在网上疯狂的购物,但对于快递员小张和小王来说,却是一个不太好过的日子。
面对成山的需要送出去的快件,小张和小王想到了一个点子,他们每人各说出自己的幸运数字(0~9,可以多个),
如果快件单号中出现了某人的幸运数字,则该人今天就派送该快件;但是,如果快件单号中两个人的幸运数字都出
现了,小张和小王都不会去派送该快件,因为他们都希望对方去送,而不是自己,因为今天实在是太忙了。
现在提供一批快件单号,请输出小张和小王各自今天要派送的快件数量。

输入格式
第一行一个整数n(n<10),为小张的幸运数字的个数;
第二行n个数(0到9之间),为小张的幸运数字;
第三行一个整数m(m<10),为小王的幸运数字的个数;
第四行m个数(0到9之间),为小王的幸运数字;
第五行一个整数T(T<=10000),为快件数
此后T行,每行一个快件单号(int范围)
输出格式
第一行小张今天要派送的快件数量
第二行小王今天要派送的快件数量
输入样例
3
2 4 6
2
0 8
3
1234
5678
333
输出样例
1
0
Hint
1234中有小张的幸运数字2和4;5678中有小张的幸运数字6,也有小王的幸运数字8;333不含幸运数字

#include
#include
int main()
{
int n,m;
int a[10],b[10];//存储小王小张的幸运数字
int count1=0,count2=0;
char ch[1000+5]; //快件单号
scanf("%d",&n);
fflush(stdin);
for(int i=0;i<n;i++)
scanf("%d",&a[i]);

scanf("%d",&m); 
fflush(stdin);
for(int i=0;i<m;i++)
scanf("%d",&b[i]); 


int T;//快件数
scanf("%d",&T);
fflush(stdin);
for(int i=0;i<T;i++){
    int flag1=0,flag2=0;
    scanf("%s",ch);
//  gets(ch);
    for(int i=0;ch[i]!='\0';i++){

        if(flag1==0)
        for(int e=0;e<n;e++){
            if(ch[i]==a[e]+'0')
            flag1=1;
        } 

        if(flag2==0)
        for(int e=0;e<n;e++){
            if(ch[i]==b[e]+'0')
            flag2=1;
        } 
    } 
    if(flag1 && flag2)continue;
    else if(flag1)count1++;
    else if(flag2)count2++;
} 
printf("%d\n%d\n",count1,count2);

return 0;

}

#include
#include
int main()
{
int n,m;
int a[10],b[10];//存储小王小张的幸运数字
int count1=0,count2=0;
char ch[1000+5]; //快件单号
scanf("%d",&n);
fflush(stdin);
for(int i=0;i<n;i++)
scanf("%d",&a[i]);

scanf("%d",&m); 
fflush(stdin);
for(int i=0;i<m;i++)
scanf("%d",&b[i]); 


int T;//快件数
scanf("%d",&T);
fflush(stdin);
for(int i=0;i<T;i++){
    int flag1=0,flag2=0;
    scanf("%s",ch);
//  gets(ch);
    for(int i=0;ch[i]!='\0';i++){

        if(flag1==0)
        for(int e=0;e<n;e++){
            if(ch[i]==a[e]+'0')
            flag1=1;
        } 

        if(flag2==0)
        for(int e=0;e<n;e++){
            if(ch[i]==b[e]+'0')
            flag2=1;
        } 
    } 
    if(flag1 && flag2)continue;
    else if(flag1)count1++;
    else if(flag2)count2++;
} 
printf("%d\n%d\n",count1,count2);

return 0;

}