求助,测试点7没过

P1618 三连击(升级版)

lww0903 @ 2022-11-09 16:31:17

为什么输入123 456 789得不到123 456 789的输出呢,想了半天也想不通

#include <stdio.h>
#define bool char
int main()
{int i,a,b,c,m[20],j,n1,n2,n3,q,w=0;
 scanf("%d%d%d",&n1,&n2,&n3);
 for(q=0;q<=((999*1.0/n3)+1);q++){
      a=q;
     b=1.0*n2*q/n1;
     c=1.0*n1*q/n2;
     m[1]=a/100;
      m[2]=a/10%10; 
      m[3]=a%10;
     m[4]=b/100; 
      m[5]=b/10%10; 
      m[6]=b%10;
     m[7]=c/100; 
      m[8]=c/10%10; 
      m[9]=c%10;
    bool t=0;
    for(j=1;j<9;j++){
       for(i=j+1;i<10;i++){
          if(m[i]==m[j]||m[j]*m[i]==0) {
            t=1;
            break;
          }
        } 
    }
    if(t==0) {printf("%d %d %d\n",a,b,c); w++;}; 
 }
 if(w==0) printf("No!!!");
return 0;
}

by lww0903 @ 2022-11-09 16:32:05

排版复制过来就变乱了,请各位谅解


by LiHuamomoda @ 2023-04-14 10:52:47

for (q = 0; q <= ((999 * 1.0 / (n3 / n1)) + 1); q++) {
    a = q;
    b = 1.0 * n2 * q / n1;
    c = 1.0 * n3 * q / n1;
    //改成这样就可以了

|