好像有点问题

P1618 三连击(升级版)

MCsky @ 2024-07-14 17:39:14


#include <iostream>
using namespace std;

bool chk(int n1,int n2,int n3){
    int a[10]={0};
    a[n1%10]++;
    a[n1/10%10]++;
    a[n1/100%10]++;
    a[n2%10]++;
    a[n2/10%10]++;
    a[n2/100%10]++;
    a[n3%10]++;
    a[n3/10%10]++;
    a[n3/100%10]++;
    for(int i=1;i<=9;i++){
        if(a[i]!=1){
            return false;
        }
    }
    return true;
}

int main(){
    int a,b,c,i,j,k,cnt=0;
    cin>>a>>b>>c;
    if(a>0&&b>0&&c>0){
        for(i=123;i<=987;i++){
            if(i%a==0){
                j=i/a*b;
                k=i/a*c;
                if(j<1000&&k<1000){
                    if(chk(i,j,k)==true){
                        cout<<i<<" "<<j<<" "<<k<<endl;
                        cnt++;
                    }
                }
            }
        }           
    }
    if(cnt==0)cout<<"No!!!"<<endl;
    return 0;
} ````
好像错了

by sutiancheng @ 2024-07-14 17:48:48

不是满分了吗???


by MCsky @ 2024-07-14 20:05:10

0分啊


by MCsky @ 2024-07-14 20:38:17


#include <iostream>
using namespace std;

bool chk(int n1,int n2,int n3){
    int a[10]={0};
    a[n1%10]++;
    a[n1/10%10]++;
    a[n1/100%10]++;
    a[n2%10]++;
    a[n2/10%10]++;
    a[n2/100%10]++;
    a[n3%10]++;
    a[n3/10%10]++;
    a[n3/100%10]++;
    for(int i=1;i<=9;i++){
        if(a[i]!=1){
            return false;
        }
    }
    return true;
}

int main(){
    int a,b,c,i,j,k,cnt=0;
    cin>>a>>b>>c;
    if(a>0&&b>0&&c>0){
        for(i=123;i<=987;i++){
            if(i%a==0){
                j=i/a*b;
                k=i/a*c;
                if(j<1000&&k<1000){
                    if(chk(i,j,k)==true){
                        cout<<i<<" "<<j<<" "<<k<<endl;
                        cnt++;
                    }
                }
            }
        }           
    }
    if(cnt==0)cout<<"No!!!"<<endl;
    return 0;
}

|