本人只会死写(好歹过了)

P1618 三连击(升级版)

cxoi9010 @ 2021-05-01 23:57:37

#include<bits/stdc++.h>
using namespace std;
int number,cnt,a,b,c,n[10],m[4][4];
bool flag[10],flag1,flag2;
int main()
{
    cin>>a>>b>>c;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            for(int k=1;k<=9;k++)
            {
                memset(flag,0,sizeof(flag));
                cnt=0;
                if(i!=j&&i!=k&&j!=k)
                {
                    n[1]=i*100+j*10+k;
                    m[1][1]=i;
                    m[1][2]=j;
                    m[1][3]=k;
                    flag[i]=flag[j]=flag[k]=1;
                    if(n[1]*1.0/a*b==int(n[1]/a*b))
                    {
                        n[2]=n[1]/a*b;
                        int r=n[2];
                        while(r!=0)
                        {
                            m[2][++cnt]=r%10;
                            flag[r%10]=1;
                            r/=10;
                        }
                        cnt=0;
                        if(n[2]*1.0/b*c==int(n[2]/b*c))
                        {
                            n[3]=n[2]/b*c;
                            int r=n[3];
                            while(r!=0)
                            {
                                m[3][++cnt]=r%10;
                                flag[r%10]=1;
                                r/=10;
                            }
                        }
                        else continue;
                        flag1=1;
                        for(int i=1;i<=9;i++)
                        {
                            if(flag[i]==0)
                            {
                                flag1=0;
                                break;
                            }
                        }
                        if(!flag1)
                        continue;
                        else
                        {
                            flag2=1;
                            cout<<n[1]<<" "<<n[2]<<" "<<n[3]<<endl;
                        }
                    }
                    else
                    continue;
                }
            }
        }
    }
    if(!flag2)
    cout<<"No!!!";
}

by haraki @ 2021-05-02 00:23:12

哦 然后呢 下一个


by int64 @ 2021-05-02 07:36:02

删帖吧,讨论区题解(


by JJA_ @ 2021-05-02 07:39:27

@cxoi9010 sbxxs cnmd爬


by 追梦之鲸 @ 2021-05-02 07:57:44

sqlm


by lao_li @ 2021-05-02 08:34:15

sqlm


by 南音同卿饮 @ 2021-05-09 16:42:44

呵呵


|