求教为什么60分

P1618 三连击(升级版)

1melon @ 2019-11-10 11:11:09

#include<stdio.h>
int main(){
    int a,b,c,t;
    int n,m,l,k;
    int num[1000];
    scanf("%d%d%d",&a,&b,&c);
    for ( n = 123; n < 987; n++)
    {
        m = n/a*b;
        l = n/a*c;
        if ((n/100+n/10%10+n%10+m/100+m/10%10+m%10+l/100+l/10%10+l%10==1+2+3+4+5+6+7+8+9)
            &&((n/100)*(n/10%10)*(n%10)*(m/100)*(m/10%10)*(m%10)*(l/100)*(l/10%10)*(l%10)==1*2*3*4*5*6*7*8*9))
        {
           if(n>m){
               k = n;
               m = n;
               m = k;
           }
           if(m>l){
               k = m;
               l = m;
               l = k;
           }
           printf("%d %d %d",n,m,l);

        t++;
        }
    }
    if(t==0) printf("No!!!");
    return 0;

}

by awa再也不水贴 @ 2019-11-10 11:22:43

优秀,等下,我思路跟你一样


by awa再也不水贴 @ 2019-11-10 11:23:19

#include <iostream>
using namespace std;
int main()
{
    double A,B,C;
    cin>>A>>B>>C;
    int a=123;
    int b,c,i=0;
    while (a<=329)
    {
        b=B/A*a;
        c=C/A*a;
        if(
            (
                a%10+a/10%10+a/100+b%10+b/10%10+b/100+c%10+c/10%10+c/100
                ==
                1+2+3+4+5+6+7+8+9
            )
            &&
            (
                (a%10)*(a/10%10)*(a/100)*(b%10)*(b/10%10)*(b/100)*(c%10)*(c/10%10)*(c/100)
                ==
                1*2*3*4*5*6*7*8*9
            )
        )
        {
        cout<<a<<" "<<b<<" "<<c<<endl;
        i++;
        }
        a++;
    }
    if(i==0) cout<<"No!!!";
    return 0;
}

by awa再也不水贴 @ 2019-11-10 11:23:49

@1melon 请自动无视括号缩进大法


by 1melon @ 2019-11-10 23:54:49

@xiaojie233a 不懂为啥第一个和最后一个点过不了 我再康康


by awa再也不水贴 @ 2019-11-11 21:42:33

@1melon 卧。。。。。艹

12点


|