80分求助

P1618 三连击(升级版)

lxc_awa @ 2022-04-04 17:47:09

#include<bits/stdc++.h>
using namespace std;
int main() {
    int a1,b1,c1,a2,b2,c2,a3,b3,c3,a[10]= {},m,j,k,o,p,q;
    cin>>o>>p>>q;
    int minn=min(o,p);
    minn=min(minn,q);
    for(int i=minn;i>=1;i--){
        if(o%i==0&&p%i==0&&q%i==0){
            o/=i;
            p/=i;
            q/=i;
        }
    }
    bool bn=false;
    int s=999/q;
    for(int i=100; i<s; i++) {
        j=i/o*p;
        k=i/o*q;
        a1=i%10;
        b1=i/10%10;
        c1=i/100;
        a2=j%10;
        b2=j/10%10;
        c2=j/100;
        a3=k%10;
        b3=k/10%10;
        c3=k/100;
        a[a1]++;
        a[b1]++;
        a[c1]++;
        a[a2]++;
        a[b2]++;
        a[c2]++;
        a[a3]++;
        a[b3]++;
        a[c3]++;
        for(int l=1; l<=10; l++) {
            if(a[l]==1) {
                m++;
            }
        }
        if(m==9) {
            cout<<i<<' '<<j<<' '<<k<<endl;
            bn=true;

        }
        for(int l=1; l<=10; l++) {
            a[l]=0;
        }
        m=0;
    }
    if(!bn){
        cout<<"No!!!";
    }
    return 0;
}

by lxc_awa @ 2022-04-05 09:03:30

谢谢,已经过了


by Hao_223777 @ 2022-04-05 21:21:54

@luxiaochi123 是最后一个点卡的吗 怎么过的呀


by lxc_awa @ 2022-04-09 20:24:31

就是最后一个点,这样过的是不是有些弱智下测试点看到的

#include<bits/stdc++.h>
using namespace std;
int main() {
    int a1,b1,c1,a2,b2,c2,a3,b3,c3,a[10]= {},m,j,k,o,p,q;
    bool bn=false;
    cin>>o>>p>>q;
    a1=o%10;
    b1=o/10%10;
    c1=o/100;
    a2=p%10;
    b2=p/10%10;
    c2=p/100;
    a3=q%10;
    b3=q/10%10;
    c3=q/100;
    a[a1]++;
    a[b1]++;
    a[c1]++;
    a[a2]++;
    a[b2]++;
    a[c2]++;
    a[a3]++;
    a[b3]++;
    a[c3]++;
    for(int l=1; l<=10; l++) {
        if(a[l]==1) {
            m++;
        }
    }
    if(m==9) {
        cout<<o<<' '<<p<<' '<<q<<endl;
        bn=true;
    }
    int minn=min(o,p);
    minn=min(minn,q);
    for(int i=minn; i>=1; i--) {
        if(o%i==0&&p%i==0&&q%i==0) {
            o/=i;
            p/=i;
            q/=i;
            break;
        }
    }
    int s=999/q;
    for(int i=100; i<=s; i++) {
        i/=o;
        j=i/o*p;
        k=i/o*q;
        a1=i%10;
        b1=i/10%10;
        c1=i/100;
        a2=j%10;
        b2=j/10%10;
        c2=j/100;
        a3=k%10;
        b3=k/10%10;
        c3=k/100;
        a[a1]++;
        a[b1]++;
        a[c1]++;
        a[a2]++;
        a[b2]++;
        a[c2]++;
        a[a3]++;
        a[b3]++;
        a[c3]++;
        for(int l=1; l<=10; l++) {
            if(a[l]==1) {
                m++;
            }
        }
        if(m==9) {
            cout<<i<<' '<<j<<' '<<k<<endl;
            bn=true;

        }
        for(int l=1; l<=10; l++) {
            a[l]=0;
        }
        m=0;
    }
    if(!bn) {
        cout<<"No!!!";
    }
    return 0;
}

by lxdyz @ 2022-05-01 00:02:40

@luxiaochi123 区别没看出来难过。


by lxc_awa @ 2022-05-01 18:39:09

@lxdyz 样例是123 456 789


by lxdyz @ 2022-05-04 22:58:53

@luxiaochi123 谢谢,我最后看文章解决了


|