为啥只有六十分,第二个第三个测试点wa

P1618 三连击(升级版)

010222wu @ 2019-12-19 19:49:27

#include<stdio.h>
int judge(int a,int b,int c)
{
    int flag[10]={1,0,0,0,0,0,0,0,0,0}; 
    flag[a%10]++;
    flag[(a/10)%10]++;
    flag[a/100]++;
    flag[b%10]++;
    flag[(b/10)%10]++;
    flag[b/100]++;
    flag[c%10]++;
    flag[(c/10)%10]++;
    flag[c/100]++;
    for(int i=1;i<10;i++)
        if(flag[i]!=1)
        return 0;
    return 1;
}
int main()
{
    int a,b,c,x,A,B,C,flag;
    scanf("%d%d%d",&a,&b,&c);
    if(a>c)
    {
        x=a;a=c;c=x;
    }
    if(a>b)
    {
        x=a;a=b;b=x;
    }
    if(b>c)
    {
        x=b;b=c;c=x;
    }
    for(A=100;C<=987;A++)
    {
        if((A*b)%a==0)
            B=A*b/a;
        else
        continue;
        if((A*c)%a==0)
            C=A*c/a;
        else
        continue;
        if(judge(A,B,C)){
        printf("%d %d %d\n",A,B,C);
        flag++;
        }
    }
    if(flag==0)
    printf("No!!!");
    return 0;

} 

by ErikaHohenzollern @ 2020-01-16 21:24:23

flag没初始化


|