2018全国多校1-I题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/fuyuyarei/article/details/79128471

唯一的一道题一次过QAQ
٩(๑>◡<๑)۶
https://www.nowcoder.com/acm/contest/67/I

#include<stdio.h>
#include<string.h>
int pd[1005];
int a,b,a1,b1,ans;
bool fuhe(int x)
{
    if(x%a==0||x%b==0) return false;
    while(x!=0)
    {
        if(pd[x%10]==1) return false;
        x=x/10;
    }
    return true;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int j=1;j<=n;j++)
    {
        scanf("%d%d",&a,&b);
    memset(pd,0,sizeof(pd));
    a1=a;b1=b;
    if(a==0||b==0) pd[0]=1;
    while(a1!=0)
    {
        pd[a1%10]=1;
        a1=a1/10;
    }
    while(b1!=0)
    {
        pd[b1%10]=1;
        b1=b1/10;
    }
    ans=0;
    for(int i=1;i<=1000;i++)
    if(fuhe(i)) ans++;
    printf("%d\n",ans);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/fuyuyarei/article/details/79128471