蒟蒻求助

P1618 三连击(升级版)

FlowNews @ 2019-07-20 18:35:57

只过了2个点

#include<bits/stdc++.h>
using namespace std;
int s[11]={};
void  div(int x)
{
    while(x>0)
    {
        s[x%10]++;
        x/=10;
    }
    return;
}
int main()
{
    int x,y,z,a,b,c;
    cin>>a>>b>>c;
    for(x=123;x<=1000;x++)
    {
        memset(s,0,sizeof(s));
        y=x*b/a;
        z=x*c/a;
        div(x);
        div(y);
        div(z);
        bool f=true;
        for(int i=1;i<=9;i++)
        {
            if(s[i]!=1)
            {
                f=false;
                break;
            }
        }
        if(f)
        {
            cout<<x<<" "<<y<<" "<<z<<endl;
        }
    }
    return 0;
}

by 幻之陨梦 @ 2019-07-20 18:37:05

@刘谅闻 给你代码

#include<bits/stdc++.h>
using namespace std;
int a,b,c,j,k,i,x,y,slj[10],s;
bool flag;
int main(){
    scanf("%d%d%d",&a,&b,&c);
    for(i=(123/a+min(123%a,1))*a;i<=987/a*a;i+=a){
        j=i/a*b;
        k=i/a*c;
        if(j>=100&&j<=999&&k>=100&&k<=999){
            s=0,y=1;
            slj[1]=i/100;
            slj[2]=i/10%10;
            slj[3]=i%10;
            slj[4]=j/100;
            slj[5]=j/10%10;
            slj[6]=j%10;
            slj[7]=k/100;
            slj[8]=k/10%10;
            slj[9]=k%10;
            for(x=1;x<=9;x++){
                s+=slj[x];
                y*=slj[x];
            }
            if(s==45&&y==362880){
                flag=1;
                printf("%d %d %d\n",i,j,k);
            }
        }
    }
    if(!flag) printf("No!!!");
    return 0;
}

|