求教

P1618 三连击(升级版)

ke0_fr @ 2016-07-09 14:20:24

第五个点过不了= =

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int book[10],num[3],a,b,c,k=0; 
int main()
{
    int i,j,t;
    scanf("%d%d%d",&a,&b,&c);
    for(i=123;i<=987;i++)
    {
        num[0]=i;
        num[1]=num[0]/a*b;
        num[2]=num[1]/b*c;
        t=0;
        memset(book,0,sizeof(book));
        book[num[0]%10]=1;
        book[num[0]%100/10]=1;
        if(num[0]/100<=9) book[num[0]/100]=1;
        book[num[1]%10]=1;
        book[num[1]%100/10]=1;
        if(num[1]/100<=9) book[num[1]/100]=1;
        book[num[2]%10]=1;
        book[num[2]%100/10]=1;
        if(num[2]/100<=9) book[num[2]/100]=1;
        for(j=1;j<=9;j++) 
        {
            if(book[j]==1) t++;
        }
        if(t==9) 
        {
           k=1;
           printf("%d %d %d\n",num[0],num[1],num[2]);
        }
    }
    if(k==0) printf("No!!!\n");
    return 0;    
}

by 落叶流云 @ 2016-07-09 16:09:56

你看看对于123 456 789这组输入你会出来什么。。。

明显增解了


by ke0_fr @ 2016-07-09 16:21:28

@落叶流云 把除号和乘号换一下之后就过了0.0,谢谢了


|